【发布时间】:2014-06-22 15:25:25
【问题描述】:
我正在尝试在我的 UIView 子类中绘制一个 V 形。出现 V 形,但我应用的线帽样式和线连接样式未反映在输出中。
- (UIBezierPath *)chevron:(CGRect)frame
{
UIBezierPath* bezierPath = [[UIBezierPath alloc]init];
[bezierPath setLineJoinStyle:kCGLineJoinRound];
[bezierPath setLineCapStyle:kCGLineCapRound];
[bezierPath moveToPoint:CGPointMake(CGRectGetMinX(frame), CGRectGetMaxY(frame))];
[bezierPath addLineToPoint:CGPointMake(CGRectGetMaxX(frame), CGRectGetMaxY(frame) * 0.5)];
[bezierPath addLineToPoint:CGPointMake(CGRectGetMinX(frame), CGRectGetMinY(frame))];
return bezierPath;
}
-(void)drawRect:(CGRect)rect{
[self.color setStroke];
UIBezierPath *chevronPath = [self chevron:rect];
[chevronPath setLineWidth:self.strokeWidth];
[chevronPath stroke];
}
根据 Apple 的文档,他们说“在配置 Bezier 路径的几何形状和属性后,您可以使用描边和填充方法在当前图形上下文中绘制路径”,但这在这里不起作用 --- 我'已经尝试移动 setLineJoinStyle 和 setLineCapStyle 语句(例如,在添加 LineToPoint 后,在 drawRect 内),似乎无论我调用它们多少次它都不起作用。任何想法出了什么问题?
【问题讨论】:
标签: ios core-graphics uibezierpath