Reputation: 306
I want to make the TextField object with the string value "Default" show its whole appearance,not be cut a half,so how should I do?
Any idea will be appreciated!
Upvotes: 1
Views: 686
Reputation: 9543
If you’re using autolayout and that’s NSTextField, just make sure it’s not height constrained in Interface Builder and it’ll always resize automatically to fit a line of text.
If you’re not using autolayout then use @boyfarrell’s -sizeToFit.
You don’t want to try to get a view to draw outside its bounds, because AppKit isn’t set up for this and so it’ll fail in a huge variety of ways. For instance, the view won’t be called and asked to redraw when the area outside its bounds is dirtied, so you’ll end up sometimes not drawing the part outside the bounds. Also, the views behind the view won’t always be cleared for the outside areas, so you’ll end up overdrawing the outside bits as well, resulting in SUPER-BOLDFACE text.
Upvotes: 1