DCA*_*ams 6 drawing objective-c ios uibezierpath
我正在创建一个应用程序,你最终必须签名,我想知道如果签名搞砸了,你将如何清除签名?
编辑:
线路类别:
#import "LinearInterpView.h"
@implementation LinearInterpView
{
UIBezierPath *path; // (3)
}
- (id)initWithCoder:(NSCoder *)aDecoder // (1)
{
if (self = [super initWithCoder:aDecoder])
{
self.backgroundColor = UIColor.whiteColor;
[self setMultipleTouchEnabled:NO]; // (2)
[self setBackgroundColor:[UIColor whiteColor]];
path = [UIBezierPath bezierPath];
[path setLineWidth:2.0];
}
return self;
}
- (void)drawRect:(CGRect)rect // (5)
{
[[UIColor blackColor] setStroke];
[path stroke];
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint p = [touch locationInView:self];
[path moveToPoint:p];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint p = [touch locationInView:self];
[path addLineToPoint:p]; // (4)
[self setNeedsDisplay];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
[self touchesMoved:touches withEvent:event];
}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
[self touchesEnded:touches withEvent:event];
}
-(void) clearPath{
path = nil;
path = [UIBezierPath bezierPath];
[self setNeedsDisplay];
}
@end
Run Code Online (Sandbox Code Playgroud)
然后在我的另一个类“SecondViewController”中,我有一个连接到 IBAction clearMethod 的按钮:
-(IBAction)clearMethod:(id)sender{
LinearInterpView *theInstance = [[LinearInterpView alloc] init];
[theInstance clearPath];
}
Run Code Online (Sandbox Code Playgroud)
它包含线路类并调用clearPath 方法。
不起作用的部分是clearPath函数内部的部分:
-(void) clearPath{
path = nil;
[self setNeedsDisplay];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9560 次 |
| 最近记录: |