ios - Bezier path not visible in view -
i copied code below stanford ios7 course adding bezier path view. however, when included code in viewdidload didn't show on screen
uibezierpath *path = [[uibezierpath alloc] init]; [path movetopoint:cgpointmake(75, 10)]; [path addlinetopoint: cgpointmake(160, 150)]; [path addlinetopoint:cgpointmake(10, 150)]; [[uicolor whitecolor] setstroke]; [[uicolor whitecolor] setfill]; [path stroke]; [path fill];
afterwards, added log statement nslog(@"path: %@", path);
prints ominous error message.
this serious error. application, or library uses, using invalid context , thereby contributing overall degradation of system stability , reliability. notice courtesy: please fix problem. become fatal error in upcoming update.
can explain doing wrong?
the error message correct. using drawing commands, not inside drawing (graphics) context. hence commands thrown away (and bad).
you should give drawing commands when within graphics context. there 2 main such situations:
you're in uiview subclass's
drawrect:
.you've created image graphics context
uigraphicsbeginimagecontextwithoptions
.
you in neither situation. can make bezier path object, constructing path, cannot draw object; commands setstroke
, stroke
illegal.
Comments
Post a Comment