I want to get the image from the UIBezierpath
closed path(See the image). I draw the image on the UIView
using drawRect
method and also draw the lines are using the drawRect
method.
How can I get the particular closed path image? Please help me. Thanks in advance.
This code used for draw the bezierpath.
UIBezierPath *aPath = [UIBezierPath bezierPath];
for (NSString *pointString in pointArray) {
if ([pointArray indexOfObject:pointString] == 0)
[aPath moveToPoint:CGPointFromString(pointString)];
else
[aPath addLineToPoint:CGPointFromString(pointString)];
}
[aPath closePath];
Well, there are a couple of things that you have to take in notice.
drawrect()
for handling that stuff for you.If you want only a portion of the image (like the cat), then you need to submask your image according to UIBezierPath.
Updated
The following is a complete working example, change it to your requirements.
ViewController.h:
ViewController.m:
use this pod ios-helpers
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
}
}
{
}
}
this works for me...
If you're drawing everything in code just use -
addClip
, i.e.:You can use a
shapeLayer
for that. Something like,To get it as an image,
image
should have the corresponding image.