uibezierpath

Parallelogram view using UIBezierPath

点点圈 提交于 2019-12-06 09:08:49
I am trying to create custom parallelogram view using UIBezierPath but not getting a perfect one. Following is my custom view code class CustomView: UIView { override func draw(_ rect: CGRect) { let offset = 60.0; let path = UIBezierPath() path.move(to: CGPoint(x: self.frame.origin.x + CGFloat(offset), y: self.frame.origin.y)) path.addLine(to: CGPoint(x: self.frame.width + self.frame.origin.x , y: self.frame.origin.y)) path.addLine(to: CGPoint(x: self.frame.origin.x + self.frame.width - CGFloat(offset) , y: self.frame.origin.y + self.frame.height)) path.addLine(to: CGPoint(x: self.frame.origin

Move UIView per UIBezierPath [closed]

回眸只為那壹抹淺笑 提交于 2019-12-06 08:06:20
Closed . This question needs to be more focused . It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post . Closed 3 years ago . I've a UIBezierPath drawing this And I want the red point to move on the blue path infinitely (from right to left, from left to right) How can I do that? You can use CAKeyFrameAnimation . Assign your path to the path property of the animation object, then run the animation on the view's layer. Edit : A little snippet as a hint: let path = ... // the UIBezierPath let animation =

How to get UIBezierPath of shape in UIImage or crop UIImage in a certain shape

那年仲夏 提交于 2019-12-06 06:14:18
问题 I am new in iOS, I want to know if I can get the UIBezierPath of a UIImage . I have a UIImage of face layout and want to get the UIBezierPath , which helps me in cropping the UIImage . Or, can any one tell me about other ways of cropping UIImage s?, but make sure cropping is in a custom shape (like: face, heart etc), not in a rectangle. 回答1: Here is the code to mask image with image : - (UIImage *)cerateImageFromImage:(UIImage *)image withMaskImage:(UIImage *)mask { CGImageRef imageRef =

Bezier path see if it crosses

爱⌒轻易说出口 提交于 2019-12-06 05:56:48
I have a code that lets the user draw a shape, I'm using UIBezierPath for this. But I need to see if the shape crosses itself, for example like this: http://upload.wikimedia.org/wikipedia/commons/0/0f/Complex_polygon.svg Then it's not a a valid shape. How can I find this? Edit: I still haven't solved this. I save all the points between the lines in the path in a array. And then I loop through the array and try to find if any lines intersects. But it does not work, sometimes it says that there is an intersection when it isn't. I think that the problem is somewhere in this method. -(BOOL

Drawing dashed line in Sprite Kit using SKShapeNode and CGPath

假装没事ソ 提交于 2019-12-06 03:28:18
问题 I want to draw a dashed line in my sprite kit game, I can use SKShapeNode node to draw a normal line like the following: UIBezierPath *_path=[UIBezierPath bezierPath]; //1 CGPoint point1 = CGPointMake(100,100); CGPoint point2 = CGPointMake(150,150); [_path moveToPoint:point1]; [_path addLineToPoint:point2]; //2 SKShapeNode *line = [SKShapeNode node]; line.path = _path.CGPath; I tried to set a dashed pattern to UIBezierPath like this: // adding this code at location 1 or 2 above but no effect

Why CGPath and UIBezierPath define “clockwise” differently in SpriteKit?

荒凉一梦 提交于 2019-12-05 20:36:13
In SpriteKit, the clockwise direction is reversed for UIBezierPath but not for CGPath . For example, if I have do { let path = CGPathCreateMutable() CGPathAddArc(path, nil, 0, 0, 10, 0, CGFloat(M_PI_2), true) let node = SKShapeNode(path: path) node.position = CGPoint(x: self.size.width/2, y: self.size.height/2) self.addChild(node) } do { let path = UIBezierPath() path.addArcWithCenter(CGPoint(x: 0, y: 0), radius: 10, startAngle: 0, endAngle: CGFloat(M_PI_2), clockwise: true) let node = SKShapeNode(path: path.CGPath) node.position = CGPoint(x: self.size.width/2, y: self.size.height/2 - 100)

Cropping an Image to the shape of an Overlay - iOS

别说谁变了你拦得住时间么 提交于 2019-12-05 19:39:47
问题 I'm adding the overlay using pickerController's view and the uinavigationcontrollerdelegate as below. -(void)navigationController:(UINavigationController *)navigationController didShowViewController: (UIViewController *)viewController animated:(BOOL)animated{ if ([navigationController.viewControllers count] == 3) { CGFloat screenHeight = [[UIScreen mainScreen] bounds].size.height; UIView *plCropOverlay = [[[viewController.view.subviews objectAtIndex:1]subviews] objectAtIndex:0]; plCropOverlay

Clip UIImage to UIBezierPath (not masking)

情到浓时终转凉″ 提交于 2019-12-05 15:45:08
I'm trying to clip a UIImage based on a given UIBezierPath , but the resulting image retains the original shape and size. I want the shape and size to resemble the path, i.e. the visible content of the new image. Take a look at this following example: The following is the code I am using to mask an image given a path: func imageByApplyingClippingBezierPath(_ path: UIBezierPath) -> UIImage { UIGraphicsBeginImageContextWithOptions(CGSize( width: size.width, height: size.height ), false, 0.0) let context = UIGraphicsGetCurrentContext()! context.saveGState() path.addClip() draw(in: CGRect(x: 0, y:

start and end angle of UIBezierPath?

徘徊边缘 提交于 2019-12-05 15:17:20
问题 I have coded as below for half circle in iOS using UIBezierPath and CAShapeLayer . clockWiseLayer = [[CAShapeLayer alloc] init]; CGFloat startAngle = -M_PI_2; CGFloat endAngle = M_PI + M_PI_2; CGFloat width = CGRectGetWidth(imageView.frame)/2.0f + 30; CGFloat height = CGRectGetHeight(imageView.frame)/2.0f +50; CGPoint centerPoint = CGPointMake(width, height); float radius = CGRectGetWidth(imageView.frame)/2+10; clockWiseLayer.path = [UIBezierPath bezierPathWithArcCenter:centerPoint radius

How can I mirror a UIBezierPath?

…衆ロ難τιáo~ 提交于 2019-12-05 15:12:27
问题 I have a UIBezierPath and I would like to get its mirror image. How can I accomplish this? // Method for generating a path UIBezierPath *myPath = [self generateAPathInBounds:boundingRect]; // ? now I would like to mirror myPath ? 回答1: // Method for generating a path UIBezierPath *myPath = [self generateAPathInBounds:boundingRect]; // Create two transforms, one to mirror across the x axis, and one to // to translate the resulting path back into the desired boundingRect CGAffineTransform