Ecco il codice di esempio:Perché il tratto di un CAShapeLayer si estende oltre la cornice?
//Called by VC:
HICircleView *circleView = [[HICircleView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
// init of circle view
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
CAShapeLayer *borderLayer = [CAShapeLayer layer];
borderLayer.fillColor = [UIColor whiteColor].CGColor;
borderLayer.path = [UIBezierPath bezierPathWithOvalInRect:self.frame].CGPath;
borderLayer.strokeColor = [[UIColor redColor] CGColor];
borderLayer.lineWidth = 5;
[self.layer addSublayer:borderLayer];
}
return self;
}
OK, grazie per la risposta. per spostare i:
CGRect rect = CGRectMake(3, 3, self.frame.size.width, self.frame.size.height);
borderLayer.path = [UIBezierPath bezierPathWithOvalInRect:rect].CGPath;
E ha reso 6 la larghezza della linea.
THanks. Puoi spiegare come spostare il percorso della linea? Non importa. Fatto. –
Ho aggiornato la mia risposta, spero che ora sia un po 'più chiara. – Sebastian