0
votes

I'm trying to make an NSTextField with only two rounded corners on the top-left and bottom-left. I tried to do the following, but in this case I get all corners rounded:

[self.myTextField:YES];
self.myTextField.layer.cornerRadius = 5;

What should I do to have only two (or for example one) rounded corners?

1
I'd give it no border and place the text field atop an image that decorates it as you see fit. You can make the image stretchable with cap insets and make the image view's layout constraints (if you're using those, I don't know how that works in OS X) match those of the text field.danh
I need to change height and width of the textField dynamically. That's why I can't use any images atop it.dvijok

1 Answers

0
votes

I'm a little out of my lane in OS X, but what you want to do is embed whatever corner art you like into an image and present those on an image view behind the NSTextField.

Resize the image view exactly as you do the text field, but first set the image's capInsets property. Size the insets to exclude the corners from scaling as the extent of the image changes. (Make sure your corner art is placed at the extreme edges of the image).