uibezierpath

UIView in cell — Can't round right-hand corners

别说谁变了你拦得住时间么 提交于 2019-12-02 07:17:50
I have a rectangular UIView object in a static table view cell. I have an outlet to the object and I'm trying to selectively round corners but it will not round corners on the right. Here's what it looks like in the storyboard: The view I want to configure is the pale yellow one. The red view serves no real purpose other than confirming that the other view is not being clipped. There are no constraint issues or errors. Here's how it looks on a 4S: I'm doing the configuration in tableView:willDisplayCell:forRowAtIndexPath: With this code ( myView is the outlet to the pale yellow view above):

How can I prevent closing Bezier Path

可紊 提交于 2019-12-02 06:14:31
I want to create a Bezier curve, and create a collision boundary for my object. let firstSurfacePoint = CGPoint(x: 30, y: 120) let secondSurfacePoint = CGPoint(x: 20, y: 200) let thirdSurfacePoint = CGPoint(x: 200, y: 300) let center = CGPoint(x: 150, y: 120) let radius: CGFloat = 120.00 let arcWidth: CGFloat = 20.00 let fourthSurfacePoint = CGPoint(x: 240, y: 300) func createCollisionPath(collision: UICollisionBehavior) { let line = UIBezierPath() line.moveToPoint(firstSurfacePoint) line.addCurveToPoint(thirdSurfacePoint, controlPoint1: secondSurfacePoint, controlPoint2: secondSurfacePoint)

Draw a path with variable width in iOS

十年热恋 提交于 2019-12-02 05:42:07
I am working on a writing application, My writing is working fine, but what I want to implement is variable stroke width , so that the writing is very realistic and intuitive, as done by " BAMBOO " and " PENULTIMATE " application. Firstly I want to tell you what I have tried. 1) In iOS, their is no pressure detection, or velocity detection according to my research. For velocity detection, I have to use OPENGL. 2) Due to these limitations, I tried using the method given in this tutorial which is pretty straight forward.Here is the link http://mobile.tutsplus.com/tutorials/iphone/ios-sdk

Masking a CAShapeLayer creates this weird artifact?

冷暖自知 提交于 2019-12-02 04:56:22
I want to create a smooth progress bar for a to-do list. I used a circle (CGMutablePath) that masks the gray area and there's an obvious arc-like artifact. Not only that but there's also an artifact on the right side of the bar. Note: I tried to rasterize the layers to no avail. What causes iOS to do this and how can I smooth this out or get rid of it? private var circleMask: CAShapeLayer = CAShapeLayer() override func layoutSubviews() { super.layoutSubviews() backgroundColor = GradientColor(.leftToRight, frame: self.bounds, colors: GradientFlatRed()) layer.cornerRadius = bounds.height / 2

Masking an image using bezierpath with image's full resolution

二次信任 提交于 2019-12-02 04:41:18
Hi, I have a path (shape) and a high-resolution image. I make the high res image to be AspectFit inside the view on which I draw the path and I want to mask the image with the path but at the full resolution of the image, not at the resolution in which we see the path. The problem, It works perfectly when I don't upscale them up for high-resolution masking but when I do, everything is messed up. The mask gets stretched and the origins don't make sense. All I want is to be able to upscale the path with the same aspect ratio of the image (at the full resolution of the image) and position it

How to create rounded UIButton with top-left & bottom-left corner radius only

北城余情 提交于 2019-12-01 19:15:54
I need to create a button with top-left & bottom-left corner radius like this one . I tried by creating the following extension that was taken from one of stackoverflow answer: extension UIButton { func roundCorners(corners:UIRectCorner, radius: CGFloat) { self.layer.borderColor = GenerateShape.UIColorFromHex(0x989898, alpha: (1.0-0.3)).CGColor self.layer.borderWidth = 1.0 let path = UIBezierPath(roundedRect: self.bounds, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius)) let mask = CAShapeLayer() mask.path = path.CGPath self.layer.mask = mask } } then called the

Draw Line Using UIPinchGeustureRecognizer

房东的猫 提交于 2019-12-01 12:14:09
I want to draw line using UIPinchGeustureRecognizer,I have tried all stackoverflow solution but no luck. please help me to resolve this. I am getting following error First i want to know my code logic is correct or not.and i didnt get the points from touchbegan/touchmoved. i am gettting two points from (void)handleLinePinch:(UIPinchGestureRecognizer *)gesture only. //My instances in .h file CGPoint location1,location2; LineView* l; - (void)viewDidLoad { [super viewDidLoad]; l = [[LineView alloc]initWithFrame:self.view.frame]; [self.view addSubview:l]; UIPinchGestureRecognizer *linepinch = [

Draw/Paint like sketch color inside a bezier path in UIView

﹥>﹥吖頭↗ 提交于 2019-12-01 10:40:15
I am drawing a shape layer with help of a UIBezier Path on a UIView : CAShapeLayer *pathLayer = [CAShapeLayer layer]; pathLayer.frame=CGRectMake(-view.frame.origin.x, -view.frame.origin.y, view.frame.size.width, view.frame.size.height); pathLayer.path = path.CGPath; pathLayer.strokeColor = [[UIColor blackColor] CGColor]; pathLayer.fillColor = [[UIColor clearColor] CGColor]; //pathLayer.fillColor = nil; pathLayer.lineWidth = 6.0; pathLayer.lineJoin = kCALineJoinBevel; [view.layer addSublayer:pathLayer]; On touch points I want to paint on that UIView, for that I am doing : -(void)touchesBegan:

Fill Color Animation Flickers when calling block in animation did stop

一曲冷凌霜 提交于 2019-12-01 09:22:23
Im having trouble figuring out why the animation is flickering from the fromValue to the toValue after my animation block is complete. I know that after you complete an animation you have to set the values of the CALayer to the end state of the animation to keep it looking consistent. Yet no matter what order i call these methods in i keep getting the flickering result. What I'm doing is drawing a checkmark with a biezer path and then once the strokeEnd animation is complete i fill in the check mark by animating the fillColor property. The fill in checkmark function and reset checkmark

Undestanding UIBezierPath curving mechanism, controlPoint and the curve point

社会主义新天地 提交于 2019-12-01 09:11:34
I'm trying to draw a simple Parabola shape using UIBezierPath . I have a maxPoint and a boundingRect of which I'm basing the width and stretch of the parabola. Here's the function I made to draw the parabola (I draw the parabola in a container view, rect will be container.bounds ): func addParabolaWithMax(maxPoint: CGPoint, inRect boundingRect: CGRect) { let path = UIBezierPath() let p1 = CGPointMake(1, CGRectGetMaxY(boundingRect)-1) let p3 = CGPointMake(CGRectGetMaxX(boundingRect)-1, CGRectGetMaxY(boundingRect)-1) path.moveToPoint(p1) path.addQuadCurveToPoint(p3, controlPoint: maxPoint) //