1

Is it possible to create a UIView with rounded edges ?

thndrkiss
  • 4,229
  • 6
  • 52
  • 92
  • 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
  • 1
    Oh, also, exact duplicate of http://stackoverflow.com/questions/1509547/uiview-with-rounded-corners. – zneak May 27 '10 at 04:17

2 Answers2

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,304
  • 4
  • 28
  • 38
-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
  • 34,250
  • 17
  • 118
  • 176