勿绮语
勿绮语

Reputation: 9320

UIButton border along rounded rect

I have a button and its type is UIButtonTypeRoundedRect, but its border does not go along the rounded corner. How can I curve the border.

Upvotes: 0

Views: 1447

Answers (2)

Mark Granoff
Mark Granoff

Reputation: 16938

Check out this blog post I recently wrote: UI Polish in An Instant

You're on the right track accessing the button's layer property, but there is more you need to do (for example, to get rounded corners, add deleteButton1.layer.cornerRadius = 10), and more you can do, all without extra images.

Upvotes: 5

Tim
Tim

Reputation: 14446

Images are the recommended method for creating custom buttons. Apple's built-in buttons are basically only there for prototyping.

You could also create a subclass of UIButton and then override the methods for drawInRect and provide custom drawing code, probably using CoreGraphics. However, it is still much cleaner in code and more efficient at runtime to just use images.

Upvotes: -1

Related Questions