5

J'utilise un UIBezierPath pour tracer une ligne courbe. La courbe fonctionne cependant, je suis incapable de courber les bords de la ligne.UIBezierPath - Ajouter un coin arrondi

enter image description here

Si vous regardez la fin du haut/bas de la courbe, vous pouvez voir que les bords sont aplaties, thats pas ce que je veux. Y a-t-il un moyen de courber les bords?

J'utilise un simple UIBezierPath pour dessiner un (presque) demi-cercle. Cela crée la forme de ligne courbe que je veux:

CAShapeLayer *circle = [CAShapeLayer layer]; 
circle.path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(0, 0) radius:70 startAngle:1.0472 endAngle:5.23599 clockwise:NO].CGPath; 
circle.fillColor = [UIColor clearColor].CGColor; 
circle.strokeColor = [UIColor colorWithWhite:1.0 alpha:0.2].CGColor; 
circle.lineWidth = 18.0; 
circle.cornerRadius = 10.0; 
circle.position = CGPointMake(100, 100); 
circle.anchorPoint = CGPointMake(0.5, 0.5); 
[mainView.layer addSublayer:circle]; 

Malgré définition de la propriété cornerRadius, les coins ne sont pas courbé. Qu'est-ce que je fais mal?

Merci pour votre temps, Dan.

Répondre

7

Inclure les éléments suivants.

circle.lineCap = kCALineJoinRound; 

Swift 3,0

circle.lineCapStyle = .Round; 
+0

Cela fonctionne parfaitement, merci! – Supertecnoboff

1

Swift 4,0

circle.lineCap = kCALineCapRound 

et si vous voulez que vos intersections de lignes à rounded également

circle.lineJoin = kCALineCapRound 

ainsi.