【发布时间】:2014-07-24 22:12:29
【问题描述】:
我被难住了,需要一些帮助。出于测试目的,我有一个通过 drawRect 绘制的 UIView(下面的代码)。我可以画一个特定角度的圆圈,但它是填充和闭合的。我需要它打开和抚摸。我目前正在使用 UIBezierPath 来执行此操作,但有更好的方法吗?我可以在 UIBezierPath 中绘制我想要的开放式三角形,但我无法指定我需要它的角度(下面的代码也是)。对此的任何帮助将不胜感激。谢谢。
下图是我希望它以特定角度绘制时的样子。
#import "AngleView.h"
#define DEGREES_TO_RADIANS(degrees) ((M_PI * degrees)/ 180)
@implementation AngleView
-(void)drawRect:(CGRect)rect {
UIBezierPath *aPath = [UIBezierPath bezierPathWithArcCenter:CGPointZero
radius:50
startAngle:0
endAngle:DEGREES_TO_RADIANS(45)
clockwise:NO];
[aPath fill];
}
@end
这是我如何在没有特定角度的情况下绘制它。
UIBezierPath* bezierPath = [UIBezierPath bezierPath];
[bezierPath moveToPoint: CGPointMake(86.5, 33.5)];
[bezierPath addLineToPoint: CGPointMake(60.5, 62.5)];
[bezierPath addLineToPoint: CGPointMake(87.5, 62.5)];
[[UIColor blackColor] setStroke];
bezierPath.lineWidth = 1;
[bezierPath stroke];
【问题讨论】:
-
你考虑过只画两条单独的线吗?
-
是的,这就是我从一开始就想做的事情,但我认为这是错误的做法并放弃了这个想法,但我想我应该这样做吧?但是,这不会使角的角看起来没有连接并且不锐利吗?谢谢。
标签: ios objective-c drawrect uibezierpath