2012-08-23 14 views
5

Ich habe dieseWie eine Grenze auf UIBezierPath bekommen

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

ich um ihn herum einen grauen Borer erhalten möchten, online zu einem viel Material ausgesehen haben, aber kann nicht einen Weg finden es einfach zu tun, ist es möglich?

Antwort

17

Wenn Sie sich nicht auf die Verwendung Schichten entgegengesetzt, so etwas wie dies könnte für Sie arbeiten:

//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

Hmm, das nicht hat überhaupt nichts Zeichnung ..? – Baconbeastnz

+2

hast du die Ebene hinzugefügt? – Brian

+0

ah jetzt funktioniert es Danke :) – Baconbeastnz