以下是我在 UITextView 上绘制角的代码。
在 .h 文件中:
@property(nonatomic,strong) UIBezierPath * upperLeft;
@property(nonatomic,strong) UIBezierPath * upperRight;
- (void)drawRect:(CGRect)rect
{
upperLeft = [UIBezierPath bezierPathWithArcCenter:CGPointMake(xCorner + margin, yCorner + margin)
radius:5.5
startAngle:0
endAngle:DEGREES_TO_RADIANS(360)
clockwise:YES];
[[UIColor blackColor]setFill];
[upperLeft fill];
[upperLeft closePath];
upperRight = [UIBezierPath bezierPathWithArcCenter:CGPointMake(xCorner+ widths - margin, yCorner + margin)
radius:5.5
startAngle:0
endAngle:DEGREES_TO_RADIANS(360)
clockwise:YES];
[[UIColor blackColor]setFill];
[upperRight fill];
[upperRight closePath];
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
touchStart = [[touches anyObject] locationInView:self];
isResizingUL = [upperLeft containsPoint:touchStart];
isResizingUR= [upperRight containsPoint:touchStart];
}
当我第一次点击路径时,它会给出布尔值是。但是对于以后的命中,它会为任何路径赋予 NO 值。即使命中路径。任何人都可以帮助我为什么会这样。