uibezierpath

please set CG_CONTEXT_SHOW_BACKTRACE environmental variable

此生再无相见时 提交于 2019-12-03 12:59:16
Despite looking over more than 3 post (made in 2015) about this problem, non have solved mine. When ever I run, a simple, code to draw a line using UIBezierPath the program would return me this: : CGContextSetStrokeColorWithColor: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. : CGContextSetFillColorWithColor: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. : CGContextSaveGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT

Actually duplicate / extract Apple's “continuous corners for iPhoneX”?

半世苍凉 提交于 2019-12-03 11:31:31
The unusual bottom corners of an iPhoneX are Apple's new (2017) "continuous corners for iPhoneX" . It is trivial for any experienced iOS programmer to approximate the curve, but: Does anyone know exactly how to achieve these, exactly as Apple does? Even if it's a private call, it would be good to know. It does seem bizarre that Apple have not explained this. Please note that it's trivial to "approximate" the curve: To repeat, it is trivial for any experienced iOS programmer to approximate the curve. The question being asked here is specifically how to do Apple actually do it? Please do not

How to change the color of a UIBezierPath in Swift?

依然范特西╮ 提交于 2019-12-03 11:24:33
I have an instance of UIBezierPath and I want to change the color of the stroke to something other than black. Does anyone know how to do this in Swift? With Swift 5, UIColor has a setStroke() method. setStroke() has the following declaration: func setStroke() Sets the color of subsequent stroke operations to the color that the receiver represents. Therefore, you can use setStroke() like this: strokeColor.setStroke() // where strokeColor is a `UIColor` instance The Playground code below shows how to use setStroke() alongside UIBezierPath in order to draw a circle with a green fill color and a

Using UIBezierPath:byRoundingCorners: with Swift 2 and Swift 3

假如想象 提交于 2019-12-03 11:06:59
问题 I'm using this code to make 2 corners of a button rounded. let buttonPath = UIBezierPath(roundedRect: button.bounds, byRoundingCorners: .TopLeft | .BottomLeft, cornerRadii: CGSizeMake(1.0, 1.0)) It throws an error: binary operator '|' cannot be applied to two UIRectCorner operands. How do I use this method in Swift 2.0? 回答1: Swift 2: let buttonPath = UIBezierPath(roundedRect: button.bounds, byRoundingCorners: [.TopLeft , .BottomLeft], cornerRadii: CGSizeMake(1.0, 1.0)) Swift 3 and Swift 4:

How to apply Curve at bottom of UIImageView?

被刻印的时光 ゝ 提交于 2019-12-03 10:01:32
问题 I want to mask and add some curve at bottom of image view. i have try below code . extension UIImage{ var roundedImage: UIImage { let rect = CGRect(origin:CGPoint(x: 0, y: 0), size: self.size) UIGraphicsBeginImageContextWithOptions(self.size, false, 1) UIBezierPath( roundedRect: rect, cornerRadius: self.size.height ).addClip() self.draw(in: rect) return UIGraphicsGetImageFromCurrentImageContext()! } } But not getting success. Let me put UI here that i want to show in screen. Let me know how

Reposition CGPath/UIBezierPath in View

让人想犯罪 __ 提交于 2019-12-03 09:43:11
问题 Is it possible to reposition an already drawn CGPath/UIBezierPath on a view? I would like to move or change a path's position then perhaps recall the drawinRect method to just show the drawing again. 回答1: From your question it sounds like you are drawing the path using Core Graphics inside drawRect: (as compared to using a CAShapeLayer ) so I'll explain the version first. Moving a CGPath You can create a new path by transforming another path. A translation transform moves the transformed

Swift draw shadow to a uibezier path

廉价感情. 提交于 2019-12-03 09:42:34
I have a strange question. Even though I did read a lot of tutorials on how to do this, the final result only shows the bezier line, not any shadow whatsoever. My code is pretty simple : let borderLine = UIBezierPath() borderLine.moveToPoint(CGPoint(x:0, y: y! - 1)) borderLine.addLineToPoint(CGPoint(x: x!, y: y! - 1)) borderLine.lineWidth = 2 UIColor.blackColor().setStroke() borderLine.stroke() let shadowLayer = CAShapeLayer() shadowLayer.shadowOpacity = 1 shadowLayer.shadowOffset = CGSize(width: 0,height: 1) shadowLayer.shadowColor = UIColor.redColor().CGColor shadowLayer.shadowRadius = 1

How to create UIBezierPath gradient fill?

╄→гoц情女王★ 提交于 2019-12-03 09:19:59
I would like to create a UIBezierPath with 10px rounded corners and with gradient fill. How can I acheive this effect? Here's an image of what I want to do: As you can see, this square has: 2px black border 10px rounded corners red to green linear gradient fill How can I do this programatically without using pattern image color ? Here's how I create the path: UIBezierPath *border = [UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:10.0f]; [border setLineWidth:2]; [[UIColor blackColor] setStroke]; [border stroke]; [[UIColor redColor] setFill]; <-- what should I put here? [border

CAShapeLayer Shadow with UIBezierPath

£可爱£侵袭症+ 提交于 2019-12-03 08:53:37
This question continues from a previous answer . I have the following CAShapeLayer : - (CAShapeLayer *)gaugeCircleLayer { if (_gaugeCircleLayer == nil) { _gaugeCircleLayer = [CAShapeLayer layer]; _gaugeCircleLayer.lineWidth = self.gaugeWidth; _gaugeCircleLayer.fillColor = [UIColor clearColor].CGColor; _gaugeCircleLayer.strokeColor = self.gaugeTintColor.CGColor; _gaugeCircleLayer.strokeStart = 0.0f; _gaugeCircleLayer.strokeEnd = self.value; _gaugeCircleLayer.lineCap = kCALineCapRound; _gaugeCircleLayer.path = [self insideCirclePath].CGPath; CAShapeLayer *cap = [CAShapeLayer layer]; cap

Need a tip with UIBezierPath. Triangle Shape like Instagram Sign Up View

南笙酒味 提交于 2019-12-03 08:36:11
I'm trying to create a bezier path like the instagram triangle in the picture below, however I must be doing something wrong. The Bezier path does not show! - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. } -(void)viewDidLayoutSubviews{ [super viewDidLayoutSubviews]; [self drawTriangle]; } - (IBAction)closeButton:(UIButton *)sender { [self dismissViewControllerAnimated:YES completion:nil]; } - (void)drawTriangle{ UIBezierPath* trianglePath = [UIBezierPath bezierPath]; [trianglePath moveToPoint:CGPointMake(self.signUpButton.center.x, self