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];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With