2013-02-26 16 views
12

भरने के बिना ड्राइंग सर्कल मैं UIImageView के अंदर एक सर्कल खींचने के लिए इस कोड का उपयोग कर रहा हूं।आईओएस

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]; 

मैं सर्कल खाली होना चाहता हूं, और केवल सीमा ही रखना चाहता हूं। मैं भरने को कैसे हटा सकता हूं?

उत्तर

18

पारदर्शी (अल्फा 0)

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

उर्फ ​​करने के लिए रंग भरने सेट करें ...

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

(धन्यवाद ज़ेव)

+4

या '[[यूआईसीओलर क्लियरकॉलर] CGColor]'। –

+1

वास्तव में ... मैं बस अपडेट करने वाला था! – foundry

3

CAShapeLayer मैनुअल पृष्ठ स्पष्ट रूप से fillColor सेट कहते हैं कोई भरण ऑपरेशन करने के लिए nil पर। यह एक पारदर्शी रंग भरने जैसा नहीं है, जिसने कुछ सुझाव देने का सुझाव दिया है, क्योंकि उत्तरार्द्ध मौजूदा सामग्री को स्पष्ट/पारदर्शी बनाने के लिए ओवरराइट करेगा, और इसे विनाशकारी ऑपरेशन माना जाना चाहिए।