Hi guys the code below makes a little gray rectangle with a dark border. The corner radio isn’t working and I cannot figure out why, I’ve tried applying maskToBounds = true, but that just hides the whole object…
How can I achieve this? Thanks
CGRect r = CGRectMake(conX, conY, 220, 50);
UIBezierPath* conPath = [UIBezierPath bezierPathWithRect:r];
CAShapeLayer* conLayer = [CAShapeLayer layer];
conLayer.path = conPath.CGPath;
conLayer.cornerRadius = 5.0;
UIColor *bg = [UIColor colorWithWhite:1 alpha:0.7];
[conLayer setFillColor:bg.CGColor];
[conLayer setStrokeColor:[UIColor grayColor].CGColor];
[[self layer] addSublayer:conLayer];
UPDATE:
You can simply use
UIBezierPath( roundedRect: CGRect, cornerRadius: CGFloat).CGPathto create your round rect pathI recommend using a round rect path instead:
where
CGPathCreateRoundRect()is