我设计了这个代码来生成一个Bezier路径,用作CAShapeLayer掩盖UIView的路径(视图的高度和宽度是可变的)
这段代码生成一个边缘锐利的三角形,但我想让它成为一个圆角!我花了好2小时试图一起工作addArcWithCenter...
,lineCapStyle
和lineJoinStyle
等,但似乎没有任何为我工作.
UIBezierPath *bezierPath = [UIBezierPath bezierPath];
CGPoint center = CGPointMake(rect.size.width / 2, 0);
CGPoint bottomLeft = CGPointMake(10, rect.size.height - 0);
CGPoint bottomRight = CGPointMake(rect.size.width - 0, rect.size.height - 0);
[bezierPath moveToPoint:center];
[bezierPath addLineToPoint:bottomLeft];
[bezierPath addLineToPoint:bottomRight];
[bezierPath closePath];
Run Code Online (Sandbox Code Playgroud)
所以我的问题是,如何在UIBezierPath中舍入三角形的所有边缘(我需要子层,多路径等)吗?
NB我没有画这个BezierPath所以所有的CGContext...
功能drawRect
都无法帮助我:(
谢谢!
我想在iOS中的图像视图上实现图像遮罩。图像遮罩应为带有圆角的六边形。可以使用某些第三方代码,但是它们没有圆角。
请帮我。因为我是iOS新手。
我想使用UIBezierPath创建一个带圆角的多边形.我相信这可以使用addCurveToPoint:controlPoint1:controlPoint2:
和http://www.codeproject.com/Articles/31859/Draw-a-Smooth-Curve-through-a-Set-of-2D-Points-wit中的类似代码,但我想知道是否有任何现有(或更好)的方法来实现这一目标?
我应该指出,这将需要针对任何凸多边形(例如在voronoi图中找到)而不仅仅是矩形形状.