This is code that I added to new view controller:
- (void)viewDidLoad
{
[super viewDidLoad];
UIView *contentView = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 200, 100)];
[contentView setClipsToBounds:YES];
[contentView setBackgroundColor:[UIColor blueColor]];
[self.view addSubview:contentView];
[[contentView layer] setBorderColor:[[UIColor lightGrayColor] CGColor]];
[[contentView layer] setBorderWidth:1.0f];
[[contentView layer] setCornerRadius:5.0f];
[[contentView layer] setMasksToBounds:YES];
}
The result:

If look at the corners we can see outside blue pixels:

You could use a CAShapeLayer :
- (void)viewDidLoad
{
[super viewDidLoad];
UIView *contentView = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 200, 100)];
[self.view addSubview:contentView];
CAShapeLayer *subLayer = [[CAShapeLayer alloc] init];
[subLayer setFillColor:[UIColor blueColor].CGColor];
[subLayer setStrokeColor:[UIColor grayColor].CGColor];
[subLayer setLineWidth:6.0];
[subLayer setPath:[UIBezierPath bezierPathWithRoundedRect:contentView.bounds cornerRadius:5.0].CGPath];
[contentView.layer addSublayer:subLayer];
}
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