ios - Draw UIBezierPaths in UIView without subclassing? -
i'm brand new using uibezierpaths draw shapes. of examples have found far involve first subclassing view, overriding drawrect:
method , doing drawing within there, haven't been able find says absolute certainty whether way draw uibezierpaths within uiview, or if pragmatic way.
is there other way (besides swizzling) draw uibezierpath in uiview without subclassing it?
another way draw bezier paths without using drawrect use cashapelayers. set path property of shape layer cgpath created bezier path. add shape layer sublayer view's layer.
uibezierpath *shape = [uibezierpath bezierpathwithovalinrect:self.view.bounds]; cashapelayer *shapelayer = [cashapelayer layer]; shapelayer.path = shape.cgpath; shapelayer.fillcolor = [uicolor colorwithred:.5 green:1 blue:.5 alpha:1].cgcolor; shapelayer.strokecolor = [uicolor blackcolor].cgcolor; shapelayer.linewidth = 2; [self.view.layer addsublayer:shapelayer];
Comments
Post a Comment