uibezierpath

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

南楼画角 提交于 2019-12-04 17:49: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

Adding a QuadCurve to UIBezierPath

情到浓时终转凉″ 提交于 2019-12-04 17:16:54
I am doing a drawing app and I am trying to smooth the line which I draw with finger.For this purpose I am using "quadCurveToPoint" function. But, I am not getting it right. Below is my code: - (void) drawRect:(CGRect)rect { [path stroke]; } - (id) initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) self.multipleTouchEnabled = NO; path = [UIBezierPath bezierPath]; path.lineWidth = IS_IPAD? 2.0f : 1.0f; return self; } - (void) touchesBegan:(NSSet *) touches withEvent:(UIEvent *) event { UITouch *touch = [touches anyObject]; m_previousPoint1 = [touch locationInView:self]; m

How to change the color of a UIBezierPath in Swift?

[亡魂溺海] 提交于 2019-12-04 16:30:56
问题 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? 回答1: 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

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

扶醉桌前 提交于 2019-12-04 15:49:23
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, firstPoint.x, firstPoint.y); for (NSString *pointString in self.touchPoints) { CGPoint point =

UIBezierPath not drawing a smooth curve

早过忘川 提交于 2019-12-04 14:14:59
问题 I am using UIBezierPath for drawing, and I have written the code on touch events and its working fine, but my curves are not smooth, when I am move my finger around and draw some curve, they are not smooth. - (void)drawRect:(CGRect)rect { [[UIColor redColor] setStroke]; for (UIBezierPath *_path in pathArray) [_path strokeWithBlendMode:kCGBlendModeNormal alpha:1.0]; } #pragma mark - Touch Methods -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { myPath=[[UIBezierPath alloc]init

How to draw Arc with curved edge in iOS?

南笙酒味 提交于 2019-12-04 14:01:42
In one of my application, I am trying to draw a gradient arc with rounded edges. Like the following image. This is what I have done so far using the following code. -(void)startArc { UIBezierPath *roundedArc = [self arcWithRoundedCornerAt:centerPoint startAngle:DEGREES_TO_RADIANS(-90) endAngle:DEGREES_TO_RADIANS(90) innerRadius:width-20 outerRadius:width cornerRadius:0]; CAShapeLayer *mask = [CAShapeLayer new]; [mask setPath:roundedArc.CGPath]; [mask setFrame:_outerView.bounds]; [mask setShouldRasterize:YES]; [mask setRasterizationScale:[UIScreen mainScreen].scale]; CAGradientLayer *gradient =

Swift draw shadow to a uibezier path

浪尽此生 提交于 2019-12-04 13:56:53
问题 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

CAShapeLayer Shadow with UIBezierPath

為{幸葍}努か 提交于 2019-12-04 13:08:09
问题 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;

iOS: How to draw text curving along a UIBezierPath?

被刻印的时光 ゝ 提交于 2019-12-04 12:05:05
I need to programmatically draw something like this:- (source: planetclegg.com ) Except that my UIBezierPath is closed & I need the text to fit inside it while following the curve. I have my path drawing correctly, the problem is the text. I've searched the 'net and read a bunch of tutorials but nothing seems to provide a solution. Is this possible in iOS, and if so how is it done? Links to relevant tutorials and/or code snippets would be much appreciated. You can see the sample code in my Github , the ArcText . Andrew Sumner Someone just pointed me to this, which appears to answer my question

How to draw multiple UIBezierPath with different colors in a UIView

▼魔方 西西 提交于 2019-12-04 11:26:25
问题 I would like to draw multiple UIBezierPath in a UIView with different stroke and fill color. Here is the code - (void)drawRect:(CGRect)rect { context = UIGraphicsGetCurrentContext(); [[UIColor grayColor] setFill]; [[UIColor greenColor] setStroke]; UIBezierPath *aPath = [[UIBezierPath alloc] init]; [aPath moveToPoint:CGPointMake(227,34.25)]; [aPath addLineToPoint:CGPointMake(298.25,34.75)]; [aPath addLineToPoint:CGPointMake(298.5,82.5)]; [aPath addLineToPoint:CGPointMake(251,83)]; [aPath