我设计了这个代码来生成一个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都无法帮助我:(
谢谢!
我有两个圆点和圆圈的中心.我想在这些点之间画一条弧.方法drawArc很简单,不符合我的目的.有人帮忙吗?
所以这是我绘制三角形的代码:
Graphics y = CreateGraphics();
Pen yy = new Pen(Color.Red);
pictureBox1.Refresh();
Point x = new Point(Convert.ToInt32(textBox1.Text)*10, Convert.ToInt32(textBox2.Text)*10);
Point xx = new Point(Convert.ToInt32(textBox3.Text)*10, Convert.ToInt32(textBox4.Text)*10);
Point xxx = new Point(Convert.ToInt32(textBox5.Text)*10, Convert.ToInt32(textBox6.Text)*10);
Point[] u = { x, xx, xxx };
y = pictureBox1.CreateGraphics();
y.DrawPolygon(yy, u);
Run Code Online (Sandbox Code Playgroud)
有没有办法围绕这个角落?我在谷歌上看到它,它似乎只有一种方法来圆角矩形,但不是三角形.
是否有任何命令要对我这样做,或者我必须手动执行此操作?
谢谢你的回复:)