2013-02-26 17 views
12

私はこのコードを使ってUIImageViewの中に円を描画しています。塗りつぶしなしの描画円IOS

CAShapeLayer *circleLayer = [CAShapeLayer layer]; 
// Give the layer the same bounds as your image view 
[circleLayer setBounds:CGRectMake(0.0f, 0.0f, [photoView bounds].size.width, 
            [photoView bounds].size.height)]; 
// Position the circle anywhere you like, but this will center it 
// In the parent layer, which will be your image view's root layer 
[circleLayer setPosition:CGPointMake(coordsFinal.x + 130, coordsFinal.y + 200)]; 
// Create a circle path. 
UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect: 
         CGRectMake(0.0f, 0.0f, 50.0f, 50.0f)]; 
// Set the path on the layer 
[circleLayer setPath:[path CGPath]]; 
// Set the stroke color 
[circleLayer setStrokeColor:[color CGColor]]; 
// Set the stroke line width 
[circleLayer setLineWidth:2.0f]; 

// Add the sublayer to the image view's layer tree 
[[photoView layer] addSublayer:circleLayer]; 

私は円を空にし、境界線のみを使用したいと思います。塗りつぶしを削除するには?明示的に設定したfillcolorのは言う透明(アルファ0)

[circleLayer setFillColor:[[UIColor colorWithWhite:0 alpha:0] CGColor]]; 

AKA ...

[circleLayer setFillColor:[[UIColor clearColor] CGColor]]; 

感謝ZEV

答えて

18

充填操作を行わない場合はnilにしてください。これは透明な色で塗りつぶすのと同じではありません。透明な色で塗りつぶすのと同じではありません。透明な色で塗りつぶすのと同じではありません。

+4

または '[[UIColor clearColor] CGColor]'です。 –

+1

確かに...私はちょうど更新しようとしていた! – foundry

3

に塗りつぶしの色にCAShapeLayerマニュアルページを設定し

関連する問題