uibezierpath

Removing lagging latency during continuous period of drawing UIBezierPath in Swift

独自空忆成欢 提交于 2019-12-23 19:35:10
问题 The code below draws lines by overriding touches, however lagging begins to occur over a period of continuous non stop drawing. This lagging accumulates and gets worse the longer the finger remains moving across the screen. The result is the CPU nearly maxes out on an actual device (CPU 98%+) and the resulting image looks choppy the longer the drawing continues. Also, when drawing extra fast especially in circles, there is a discrepancy in the paths drawn between the path and temporaryPath

Rounder by UIBezierPath issue when scrolling

烈酒焚心 提交于 2019-12-23 17:47:15
问题 I am new in iOS. I am make a chat application. I am using UITableView for display the message chat (one cell - one message). In each cell, I will rounder the message in 2,3 or 4 corner (like Facebook chat) For rounder I use the UIBezierPath inside layoutSubView of each Tableview Cell UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.messageView.bounds byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerBottomLeft) cornerRadii:CGSizeMake(3.0, 3.0)]; CAShapeLayer *maskLayer

How can I change the color of an element using a UIBezierPath?

一笑奈何 提交于 2019-12-23 12:58:04
问题 First post on stackoverflow so, first and foremost, hello! I'm trying my hand at Swift for the first time and am working a project and just needed some help on a problem I'm having. I've got a circle using a UIBezierPath that I'd like to change the color of, dynamically. However, when I try to even "hard code" the color, I'm unable to get it to change. I've tried looking here: How to change the color of a UIBezierPath in Swift?, but it didn't answer my question. However, I do see that one

How to draw variable-width UIBezierPath?

跟風遠走 提交于 2019-12-23 12:14:03
问题 I'm wondering how I should go about drawing a uibezierpath where the stroke width peaks at the center of the arc. Here's an example of what I mean: Either I have to go through each point when drawing, and set the stroke width accordingly, or there's an easier way. Can anyone point me in the right direction? Thanks 回答1: You can just draw the two outer paths with no stroke, join them, and then fill in the space between them. 回答2: Another way to try this if you're interested: I ended up getting

How to scale a CAShapeLayer

房东的猫 提交于 2019-12-23 11:57:48
问题 In swift I've successfully made an animated bezier path which is contained inside a CAShapeLayer . My only problem is implementing it onto other screen sizes. Does anybody know how I can scale the CAShapeLayer with the path inside of it? i.e. make it half the original size. 回答1: Use this function: var shapelayer:CAShapeLayer shapelayer.transform = CATransform3DMakeScale(, ,) 来源: https://stackoverflow.com/questions/29740090/how-to-scale-a-cashapelayer

How to fill space between two UIBezierPaths

烈酒焚心 提交于 2019-12-23 04:28:16
问题 I'm working on drawing application which provides drawing lines with variable line width which depends on drawing speed. This behavior inspired by Paper app. Algorithm which I'm trying to implement -- draw two bezier path with variable distance between them. The solution which described in sosborn's answer. Then smooth paths and fill the distance between them. Actually I don't figured out how to fill space between paths. 回答1: You create a single path from the 2 bezier curves and fill it, like

What is the Best Way To show UITextField with only a bottom border?

泪湿孤枕 提交于 2019-12-23 01:54:20
问题 I would like to have UITextField appear only with a bottom border. See the designer's image below: UIBezierPath *path = [UIBezierPath bezierPath]; [path moveToPoint:CGPointMake(150.0, 350.0)]; [path addLineToPoint:CGPointMake(250.0, 209.0)]; CAShapeLayer *shapeLayer = [CAShapeLayer layer]; shapeLayer.path = [path CGPath]; shapeLayer.strokeColor = [[UIColor blueColor] CGColor]; shapeLayer.lineWidth = 3.0; shapeLayer.fillColor = [[UIColor clearColor] CGColor]; I have Tried This but not Getting

Parallelogram view using UIBezierPath

会有一股神秘感。 提交于 2019-12-22 19:35:12
问题 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 -

Swift - Clipping image with UIBezierPath

六月ゝ 毕业季﹏ 提交于 2019-12-22 17:52:03
问题 I would like to clip a bezier path from an image. For some reason, the image remains the unclipped. And how do I position the path so it would be properly cut? extension UIImage { func imageByApplyingMaskingBezierPath(_ path: UIBezierPath, _ pathFrame: CGFrame) -> UIImage { UIGraphicsBeginImageContext(self.size) let context = UIGraphicsGetCurrentContext()! context.saveGState() path.addClip() draw(in: CGRect(x: 0, y: 0, width: self.size.width, height: self.size.height)) let maskedImage =

Empty drawRect implementation causes memory warning

不羁的心 提交于 2019-12-22 17:42:02
问题 I have a UIView on which I draw a UIBezierPath by finger. When I rezoom the view (say after a path is drawn) a redraw function is triggered, which rescales the BezierPath: - (void)redrawPathsWithScale:(float)scale { [_path applyTransform:CGAffineTransformMakeScale(scale, scale)]; [self setNeedsDisplay]; } setNeedsDisplay causes drawRect to get called. Now every time I zoom in to a absolute scale somewhere near x6 I immediately get a memory warning, and the App crashes. My drawRect method