ViewControllerタイプの同じビュー内の2つの異なるポイント間に線を描画したいだけです。次のコードを記述しましたが、線が表示されません。この問題の解決にご協力ください。
- (void)drawRect:(CGRect)rect
{
[brushPattern setStroke];
[myPath strokeWithBlendMode:kCGBlendModeNormal alpha:1.0];
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *mytouch=[[touches allObjects] objectAtIndex:0];
// CGPoint *point=mytouch
[myPath moveToPoint:[mytouch locationInView:self.view]];
CGPoint pos = [mytouch locationInView: self.view];
NSLog(@"Position of touch: %.3f, %.3f", pos.x, pos.y);
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *mytouch=[[touches allObjects] objectAtIndex:0];
[myPath addLineToPoint:[mytouch locationInView:self.view]];
[self.view setNeedsDisplay];
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *mytouch=[[touches allObjects] objectAtIndex:0];
CGPoint pos = [mytouch locationInView: self.view];
NSLog(@"Position of touch: %.3f, %.3f", pos.x, pos.y);
}