uibezierpath

iOS: Inverse UIBezierPath (bezierPathWithOvalInRect)

北城以北 提交于 2019-12-05 10:59:57
问题 I have an jpg Image with a round object in a rect and want to make the envoirement of the round object transparent... (Remove red area in this example) With the help of this iOS make part of an UIImage transparent and "UIBezierPath bezierPathWithOvalInRect" i've got a little success, but this make a path around my object, and I need to invert it, to make the outside and not the inside of the path transparent.. Im not shure where I have to change my code to get the right result.. Here is my

UIBezierPath叠加的相加相减显示

瘦欲@ 提交于 2019-12-05 04:37:49
-(void)addBlankFrames:(NSArray<__kindof NSValue *> *)frames { UIBezierPath *path = self.blankPath?:[UIBezierPath bezierPath]; CGRect oldRect = CGRectZero; for (NSValue *value in frames) { CGRect frame = [value CGRectValue]; UIBezierPath *p = [UIBezierPath bezierPathWithRect:frame]; if (oldRect.size.width > 0 && oldRect.size.height > 0) { [p appendPath:[[UIBezierPath bezierPathWithRect:CGRectIntersection(frame, oldRect)] bezierPathByReversingPath]]; } [path appendPath:p]; oldRect = frame; } [path closePath]; self.blankPath = path; UIBezierPath *showPath = [UIBezierPath bezierPathWithRect:self

干货系列之手把手教你使用Core animation 做动画

折月煮酒 提交于 2019-12-05 03:34:32
原文出处: Airfei 源码下载: 源码 最近在技术群里,有人发了一张带有动画效果的图片。觉得很有意思,便动手实现了一下。在这篇文章中你将会学到Core Animation显式动画中的关键帧动画、组合动画、CABasicAnimation动画。先上一张原图的动画效果。 点击此查看 原图动画效果 。 本文要实现的效果图如下: 实现的效果图.gif 把原动画gif动画在mac上使用图片浏览模式打开,我们可以看到动画每一帧的显示。从每一帧上的展示过程,可以把整体的动画进行拆分成两大部分。 第一部分(Part1)从初始状态变成取消状态(图片上是由横实线变成上线横线交叉的圆)。 第二部分(Part2)从取消状态变回初始状态。 下面我们先详细分析Part1是怎么实现的。根据动画图,把Part1再细分成三步。 Step1 : 中间横实线的由右向左的运动效果。这其实是一个组合动画。是先向左偏移的同时横线变短。先看一下实现的动态效果。 step1 Animation.gif ■ 向左偏移—使用基本动画中 animationWithKeyPath 键值对的方式来改变动画的值。我们这里使用 position.x ,同样可以使用 transform.translation.x 来平移。 ■ 改变横线的大小—使用经典的 strokeStart 和 strokeEnd 。其实上横线长度的变化的由

Drawing a line with Bezierpath using CAShapeLayer object

梦想的初衷 提交于 2019-12-05 03:23:01
I am making an image editor which can create different shapes objects like circle, triangle and square which can also be updated or removed. So I have used CAShapeLayer for creating shapes objects. Now I also want to draw a line on image which can also be updated or removed so I have used bezierpath and CAShapeLayer to create the line, it is working fine. BUT now the problem is that when I want to select any existing line it can be selected any where close to line tool because CAShapeLayer also set the fill region which will be a straight line from start point to end point. My question is that

How to set Corner Radius to UIBezierPath

旧城冷巷雨未停 提交于 2019-12-05 02:57:31
问题 I have created following image by UIBezierPath using this code //// Bezier Drawing let bezierPath = UIBezierPath() bezierPath.move(to: CGPoint(x: 360, y: 0)) bezierPath.addCurve(to: CGPoint(x: 360, y: 75), controlPoint1: CGPoint(x: 359.53, y: 30.5), controlPoint2: CGPoint(x: 359.91, y: 55.45)) bezierPath.addCurve(to: CGPoint(x: 360, y: 153.78), controlPoint1: CGPoint(x: 360.35, y: 153.21), controlPoint2: CGPoint(x: 360, y: 153.78)) bezierPath.addCurve(to: CGPoint(x: 180, y: 153.78),

Adjusting the line to fit our head in imageview

末鹿安然 提交于 2019-12-05 01:31:03
I am developing one application same as HairTryOn all things are done. but problem is display in following image. i want to set hair style as per customer face using blue line as per display in image. i used the following code testVw = [[UIView alloc]initWithFrame:CGRectMake(100,100, 100, 100)]; testVw.backgroundColor = [UIColor clearColor]; [self.view addSubview:testVw]; resizeVw = [[UIImageView alloc]initWithFrame:CGRectMake(testVw.frame.size.width-25, testVw.frame.size.height-25, 25, 25)]; resizeVw.backgroundColor = [UIColor clearColor]; resizeVw.userInteractionEnabled = YES; resizeVw.image

Round Top Corners of a UIView in Swift

一个人想着一个人 提交于 2019-12-05 01:14:44
问题 I am trying to round top corners using below code func roundCorners(corners:UIRectCorner, radius: CGFloat) { let path = UIBezierPath(roundedRect: self.bounds, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius)) let maskLayer = CAShapeLayer() maskLayer.frame = self.bounds maskLayer.path = path.cgPath self.layer.mask = maskLayer } use myView.roundCorners(corners:[.topLeft, .topRight], radius: radius) But it's rounding one side of the view: this is in a tableView

UIbezierpaths in a zoomable view

℡╲_俬逩灬. 提交于 2019-12-04 22:37:31
问题 I draw bezierpaths in a zoomable UIView (drawing layer of a pdf reader). When I zoom in the document the UIView zoom in too, but then all the drawings and lines looks much more pixelated. Is there a way to render those paths without too much pixelation? It supposed that bezier paths are vectorial based... Thanks in advance! 回答1: You are correct that a UIBezierPath is vector based. However, when you draw a path into a view, it uses the contentScale property on the views layer to determine the

What is the difference between closing the bezier path using closePath function and closing it manually?

时光毁灭记忆、已成空白 提交于 2019-12-04 19:42:10
问题 I am trying to make a rectangle using UIBezierPath . I adopted two different ways to draw it. Also, I increased the stroke width to 25 px. First method : Using closePath UIBezierPath *bpath = [UIBezierPath bezierPath]; [bpath moveToPoint:CGPointMake(x, y)]; [bpath addLineToPoint:CGPointMake(x + w, y)]; [bpath addLineToPoint:CGPointMake(x + w, y + h)]; [bpath addLineToPoint:CGPointMake(x, y + h)]; [bpath closePath]; Output: Second method : Closing the path manually UIBezierPath *bpath =

ios detecting line angle or degree

末鹿安然 提交于 2019-12-04 17:59:14
I'm new to iOS , i am trying to develop a freehand drawing app, using uibezierPath .is there a way to calculate or receive the total line length, even if i drew straight line, curved or a circle. i am using addline on the the touchmove method, and i don't have any control points. Inside your touchesBegan method, you can use this code { UITouch * touch = [touches anyObject]; CGPoint present = [touch locationInView:self]; CGPoint previous = [touch previousLocationInView:self]; CGFloat angle = [self getAngle:present :previous]; } - (float) getAngle:(CGPoint)a :(CGPoint)b { int x = a.x; int y = a