uibezierpath

Drawing a line with Bezierpath using CAShapeLayer object

喜欢而已 提交于 2019-12-06 23:47:41
问题 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

How to disable TouchUpInside Action outside the boundary of button

你说的曾经没有我的故事 提交于 2019-12-06 15:53:32
This is my Xib. I just dragged a UIButton and changed its background color. I created a semi circle layer using this code let circlePath = UIBezierPath.init(arcCenter: CGPointMake(mybutton.bounds.size.width / 4, 0), radius: mybutton.bounds.size.height, startAngle: 0.0, endAngle: CGFloat(M_PI), clockwise: true) let circleShape = CAShapeLayer() circleShape.path = circlePath.CGPath mybutton.layer.mask = circleShape and this is my output. Its perfect as I want it. But the problem is that this button is clickable outside its rounded area(as per actuall shape of button). I want it to be clickable

Drawing curved lines without lagging?

狂风中的少年 提交于 2019-12-06 14:40:43
I have a class below that when attached to a view draws curved lines when the user touches their device. The problem is that the lines drawn seem to lag behind from the position of the finger on the screen. The lagging is enough to be noticeable and mildly annoying as new sections of the line display a small distance away from the finger touching the screen. The code uses the addCurveToPoint curve method. (The alternative addQuadCurveToPoint curve method appears to be less superior in terms of a quality curved line but does display on screen faster.) I suspect that this issue relates to when

Create a UIView with rounded top edge

牧云@^-^@ 提交于 2019-12-06 14:37:54
I would like to create an UIView with rounded top edge like this image, how can I do it please? Wanted result Not wanted result To repost an answer I posted on a different thread: I can now confirm that this is a bug introduced after iOS 6. I have an old 4s running iOS 6.1. On that machine, this code: path = [UIBezierPath bezierPathWithRoundedRect: bounds byRoundingCorners: UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii: CGSizeMake(bounds.size.width/2, bounds.size.width/6) ]; Creates a rounded rectangle with the corners oval-shaped. The curve is much more gradual on the top part of the

“Launch” and drop a UIView

萝らか妹 提交于 2019-12-06 13:52:05
问题 Above picture illustrates what I want: The red circle is the starting point of a UIView I want to launch it upwards (Y position) with a change in the X position I want to make it drop within boundaries. What I tried: For the launch I can make use of the UIView.animate function. For the drop I can use the UIDynamicAnimator. However there are some problems: -In the UIView.animate I cannot 'curve' the animation, only a straight line. I can use this answer here to draw a curve line: https:/

UIBezierPath appending overlapping isn't filled

若如初见. 提交于 2019-12-06 12:56:29
I'm trying to merge two overlapping UIBezierPaths using UIBezierPath.append , and I want the overlapping space to be filled. I tried setting the usesEvenOddFillRule property to false , but it still doesn't fill. Here is minimal example of the problem: override func draw(_ rect: CGRect) { let firstShape = UIBezierPath() firstShape.move(to: CGPoint(x: 100, y: 100)) firstShape.addLine(to: CGPoint(x: 100, y: 150)) firstShape.addLine(to: CGPoint(x: 150, y: 170)) firstShape.close() let secondShape = UIBezierPath(rect: CGRect(x: 125, y: 125, width: 75, height: 75)) let combined = UIBezierPath()

How to encode UIBezierPath to SVG?

依然范特西╮ 提交于 2019-12-06 11:16:36
I have a simple view for finger painting / drawing. I store the drawings as UIBezierPath s in a NSMutableArray . Now I want to transfer the drawings to a web-service for presenting them in a browser. Therefore I need to encode my UIBezierPath s in a SVG-file - because this the format of the web-service. What I found right now is the SVGKit , which only DECODES SVG. Do anybody know sample code, snippets or a framework for encoding SVG? Thank you. bitmapdata.com I tested yet. but using following steps: Would not it be possible? 1.UIBezierPath to CGPathRef. UIBezierPath to CGPathRef 2.Using a

How to create a crescent moon using bezier paths in iOS?

时光毁灭记忆、已成空白 提交于 2019-12-06 10:11:35
问题 How to draw a closed crescent moon using bezier paths, when the stroke and fill are configurable? So car I can get once curve but haven't found a strategy to connect and draw the other curve. 回答1: If you want something better approximating an astronomically correct crescent (where the outer arc is 180 degrees), I might suggest something like: CGFloat angle = M_PI_2 * 0.60; // how much of a crescent do you want (must be less than M_PI_2 and greater than zero) UIBezierPath *path = [UIBezierPath

UIView shadow issue with orientation

纵然是瞬间 提交于 2019-12-06 10:04:08
I have UiTableView within UiView . I want to set corner radius & shadow to UIView . I am using this code to give shadow with corner and its working fine. myView.backgroundColor = [UIColor clearColor]; [myView.layer setCornerRadius:10.0f]; [myView.layer setBorderColor:[UIColor lightGrayColor].CGColor]; [myView.layer setBorderWidth:1.0f]; [myView.layer setShadowColor:[UIColor blackColor].CGColor]; [myView.layer setShadowOpacity:0.8]; [myView.layer setShadowRadius:3.0]; [myView.layer setShadowOffset:CGSizeMake(2.0, 2.0)]; // below line is for smooth scrolling [myView.layer setShadowPath:

How to find the closing path(two line intersection) in iPhone SDK?

杀马特。学长 韩版系。学妹 提交于 2019-12-06 09:12:00
问题 Please see the image. How can I get the two line intersection point(that is green rounded point)? I want to crop the inner part of the image. The closing path is any where in the line. context = UIGraphicsGetCurrentContext(); CGContextBeginPath(context); CGContextSetLineWidth(context, 1.0 * self.scale); CGContextSetLineCap(context, kCGLineCapRound); [[UIColor redColor] setStroke]; CGPoint firstPoint = CGPointFromString([self.touchPoints objectAtIndex:0]); CGContextMoveToPoint(context,