Is it possible to create a UIView with rounded edges ?
Asked
Active
Viewed 1,290 times
1
-
Mostly a duplicate of http://stackoverflow.com/questions/510382/how-do-i-create-a-round-cornered-uilabel-on-the-iphone; the question's not exactly the same, but the answer implies UIViews only (since UILabels are UIViews). – zneak May 27 '10 at 04:16
-
1Oh, also, exact duplicate of http://stackoverflow.com/questions/1509547/uiview-with-rounded-corners. – zneak May 27 '10 at 04:17
2 Answers
1
From the other stackoverflow questions listed above...
3.0 and Later
iPhone OS 3.0 and later supports the cornerRadius property on the CALayer class. Every view has a CALayer instance that you can manipulate. This means you can get rounded corners in one line now:
view.layer.cornerRadius = 8;
You will need to #import <QuartzCore/QuartzCore.h>
and link to the QuartzCore framework to get access to CALayer's headers and properties.

OscarTheGrouch
- 2,374
- 4
- 28
- 39
-1
You can subclass UIView and override its drawBounds routine to draw its edges rounded, but the bounds of any UIView or subclass will always be a rectangle.

fbrereto
- 35,429
- 19
- 126
- 178