volte raggio d'angolo con bordo bianco non funziona correttamente per cui uso UIBezierPath
e CAShapeLayer
.
Per rendere il raggio d'angolo
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;
Per rendere il bordo bianco
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];
Funzionerà. Spero che questo aiuto
fonte
2016-03-24 01:54:35
CALayer fa parte di Core Animation, non di UIKit. Pertanto, prende un CGColor, non UIColor. – MarkPowell
Oh sì, scusa, stavo scrivendo quello dalla mia testa. –