Iphone – How to draw a rounded rectangle in Core Graphics / Quartz 2D

iphonequartz-graphics

I need to draw an outline for a rounded rectangle. I know I can make lines and arcs, but maybe there is also a function for rounded rects?

Best Answer

Instead of making your own path out of lines and arcs, you can use

[UIBezierPath bezierPathWithRoundedRect:cornerRadius:]

or

[UIBezierPath bezierPathWithRoundedRect:byRoundingCorners:cornerRadii:]

(the second one lets you specify which corners are rounded)

Available in iOS 3.2 or later.