iphone - How can i draw a dot on the screen on touchesEnded using UIBezierpath -
can here please show me how draw single dot using uibezierpath. able draw line using uibezierpath if remove finger , put , remove nothing drawn on screen. thanks
- (void)touchesended:(nsset *)touches withevent:(uievent *)event {
uitouch *touch = [touches anyobject]; cgpoint p = [touch locationinview:self]; [ppath movetopoint:p]; [ppath stroke]; [self setneedsdisplay]; }
- (void)drawrect:(cgrect)rect {
[ppath stroke]; }
your path doesn't include line or curve segments stroked.
try instead:
- (void)touchesended:(nsset *)touches withevent:(uievent *)event { cgpoint p = [touches.anyobject locationinview:self]; static cgfloat const kradius = 3; cgrect rect = cgrectmake(p.x - kradius, p.y - kradius, 2 * kradius, 2 * kradius); ppath = [uibezierpath bezierpathwithovalinrect:rect]; [self setneedsdisplay]; } - (void)drawrect:(cgrect)rect { [[uicolor blackcolor] setfill]; [ppath fill]; }
Comments
Post a Comment