Possible Duplicate:
UIView with rounded corners
I want to have a view with rounded corners rather then sharp. Is there some default way of doing this?
Possible Duplicate:
UIView with rounded corners
I want to have a view with rounded corners rather then sharp. Is there some default way of doing this?
You can do this by manipulating the layer
of the view and its masksToBounds
property. I have the following code in a UIView
category:
#import <QuartzCore/QuartzCore.h>
...
- (void)addRoundedCornersWithRadius:(NSInteger)cornerRadiusInPixels
{
self.layer.cornerRadius = cornerRadiusInPixels;
self.layer.masksToBounds = YES;
self.opaque = NO;
}
- (void)makeEndsRounded
{
CGFloat minSide = fmin(self.bounds.size.width, self.bounds.size.height);
[self addRoundedCornersWithRadius:minSide/2];
}
Not that I know of - since UIViews
are specified by CGRects
they are technically always rectangular. If you want a rounded effect, you need a background image with rounded corners.