the square kind... (not rounded)
Im trying to make a background that fits my texfield and cant seem to find the height (default) anywhere
the square kind... (not rounded)
Im trying to make a background that fits my texfield and cant seem to find the height (default) anywhere
Default height is 31pts (you can see that in IB), but it is fixed only for rounded border style - with all other styles you can set field height to arbitrary value.
btw, you can find a reference for common UI elements sizes here
[textField sizeThatFits:textField.frame.size].height
If you hard-code 31pts then you will have unsightly visual errors if (when) Apple ever changes the size.
For iOS and iPadOS 14.5. The default height is 34 points for the rounded border style as seen in the Interface Builder.
However, this value can change. To check the size use the following code snippet.
let textField = UITextField()
textField.borderStyle = .roundedRect
print (textField.sizeThatFits(textField.frame.size).height)
Output
34.0
UITextField is a subclass of UIView so you can send -frame
or -bounds
to the object.
© 2022 - 2024 — McMap. All rights reserved.