ios - UIButton in PaintCode (Swift) -
so i've been playing around paintcode , stylekits in xcode. made button, created uiview it's own subclass, , shows fine in viewcontroller , on device. however, want transform uiview uibutton, want code execute when it's tapped. how go doing this?
thanks guys , have 1 :)
i use paintcode's uiimage method, , use uiimage uibutton's image. here's code use, in objc, should converted swift.
paintcode's generated code - stuff don't need write (pretend class called paintcodeclass):
+ (uiimage*)imageoficon { if (_imageoficon) return _imageoficon; uigraphicsbeginimagecontextwithoptions(cgsizemake(30, 30), no, 0.0f); [paintcodeclass drawicon]; _imageoficon = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); return _imageoficon; }
and code:
uiimage *image = [paintcodeclass imageoficon]; uibutton *button = (initialize, set frame, etc) [button setimage:image forstate:uicontrolstatenormal];
some people better:
[button setbackgroundimage:image forstate:uicontrolstatenormal];
instead of that, if wanted to, do:
[button addsubview:whateverthepaintcodeviewiscalled];
but wouldn't behave button - don't want that.
Comments
Post a Comment