2012-08-23 12 views
5

पर एक सीमा प्राप्त करने के लिए मैं इसकैसे UIBezierPath

CGRect container = CGRectMake(conX, conY, 220, 50); 
    UIBezierPath* path = [UIBezierPath bezierPathWithRoundedRect:container cornerRadius:5.0]; 
    [[UIColor blueColor] setFill]; 
    [path fillWithBlendMode:kCGBlendModeNormal alpha:0.7]; 

मैं इसे चारों ओर एक ग्रे छिद्रक प्राप्त करना चाहते हैं, सामान का एक बहुत ऑनलाइन ध्यान दिया है, लेकिन यह आसानी से करने के लिए एक तरह से नहीं देख सकते हैं, क्या यह संभव है?

उत्तर

17

आप परतों का उपयोग करने के लिए विरोध नहीं कर रहे हैं, कुछ इस तरह आप के लिए काम कर सकता था:

//create triangle path 
UIBezierPath* path = [UIBezierPath bezierPath]; 
[path moveToPoint:CGPointMake(0, 30)]; 
[path addLineToPoint:CGPointMake(100, 30)]; 
[path addLineToPoint:CGPointMake(100, 0)]; 
[path addLineToPoint:CGPointMake(0, 30)]; 

//apply path to shapelayer 
CAShapeLayer* greenPath = [CAShapeLayer layer]; 
greenPath.path = path.CGPath; 
[greenPath setFillColor:[UIColor greenColor].CGColor]; 
[greenPath setStrokeColor:[UIColor blueColor].CGColor]; 
greenPath.frame=CGRectMake(0, 0,100,30); 

//add shape layer to view's layer 
[[self layer] addSublayer:greenPath]; 
+0

हम्म कि कुछ भी ड्राइंग नहीं कर रहा है ..? – Baconbeastnz

+2

क्या आपने परत जोड़ दी? – Brian

+0

आह अब इसके कामकाजी धन्यवाद :) – Baconbeastnz

संबंधित मुद्दे