Иногда радиус закругления с белой каймой не работает должным образом поэтому я использую UIBezierPath
и CAShapeLayer
.
Для сделать угловой радиус
UIBezierPath *maskPath;
maskPath = [UIBezierPath bezierPathWithRoundedRect:self.imageView.bounds byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerTopRight | UIRectCornerBottomLeft | UIRectCornerBottomRight) cornerRadii:CGSizeMake(10.0, 10.0)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = self.view.bounds;
maskLayer.path = maskPath.CGPath;
self.imageView.layer.mask = maskLayer;
Для сделать границу белого
CAShapeLayer* borderShape = [CAShapeLayer layer];
borderShape.frame = self.imageView.bounds;
borderShape.path = maskPath.CGPath;
borderShape.strokeColor = [UIColor whiteColor].CGColor;
borderShape.fillColor = nil;
borderShape.lineWidth = 3;
[self.imageView.layer addSublayer:borderShape];
Он будет работать. Надеюсь, эта помощь
CALayer является частью Core Animation, а не UIKit. Следовательно, требуется CGColor, а не UIColor. – MarkPowell
О да, извините, я просто печатал это с моей головы. –