How to get border on UIBezierPath

I have it

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

I want to get a gray buffer around it, looked a lot of material on the Internet, but I see no way to make it easy, is it possible?

+5
source share
1 answer

If you don't mind using layers, something like this might work for you:

 //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 layer [[self layer] addSublayer:greenPath]; 
+17
source

Source: https://habr.com/ru/post/974492/


All Articles