Creating a rounded-corner view

ios, objective-c

Solution

Try something like this:

view.layer.cornerRadius = 5.0;
view.layer.masksToBounds = YES;

for shadow:

view.layer.shadowColor = [UIColor blackColor].CGColor;
view.layer.shadowOffset = CGSizeMake(1.0f, 1.0f);
view.layer.masksToBounds = NO;
view.layer.shadowRadius = 5.0f;

Make sure to import `<QuartzCore/QuartzCore.h>`

Problem

Good day! Im trying to make my view (view in main view) make rounded corner. Im doing like this, but it doesn't work. Any ideas? ``` self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization currenView = [[UIView alloc] init]; UIBezierPath *maskPath; maskPath = [UIBezierPath bezierPathWithRoundedRect:currenView.bounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(30.0, 30.0)]; CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; maskLayer.frame = currenView.bounds; maskLayer.path = maskPath.CGPath; currenView.layer.mask = maskLayer; } return self; ```

Original source

Related problems