Graphics Reference
In-Depth Information
self
.
path
.
lineWidth
=
5
;
}
- (
void
)touchesBegan:(
NSSet
*)touches withEvent:(
UIEvent
*)event
{
//get the starting point
CGPoint
point = [[touches
anyObject
]
locationInView
:
self
];
//move the path drawing cursor to the starting point
[
self
.
path
moveToPoint
:point];
}
- (
void
)touchesMoved:(
NSSet
*)touches withEvent:(
UIEvent
*)event
{
//get the current point
CGPoint
point = [[touches
anyObject
]
locationInView
:
self
];
//add a new line segment to our path
[
self
.
path
addLineToPoint
:point];
//redraw the view
[
self
setNeedsDisplay
];
}
- (
void
)drawRect:(
CGRect
)rect
{
//draw path
[[
UIColor
clearColor
]
setFill
];
[[
UIColor
redColor
]
setStroke
];
[
self
.
path
stroke
];
}
@end