I use PaintCode's UIImage method, and use that UIImage as the UIButton's image. Here's code I use, which is in ObjC, but should be easily converted to Swift.
PaintCode's generated code - the stuff you don't need to write (pretend this class is called PaintCodeClass):
+ (UIImage*)imageOfIcon
{
if (_imageOfIcon)
return _imageOfIcon;
UIGraphicsBeginImageContextWithOptions(CGSizeMake(30, 30), NO, 0.0f);
[PaintCodeClass drawIcon];
_imageOfIcon = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return _imageOfIcon;
}
and my code:
UIImage *image = [PaintCodeClass imageOfIcon];
UIButton *button = (initialize, set frame, etc)
[button setImage:image forState:UIControlStateNormal];
Some people like this better:
[button setBackgroundImage:image forState:UIControlStateNormal];
Instead of all that, if you really wanted to, you could do:
[button addSubview:whateverThePaintCodeViewIsCalled];
but that wouldn't behave like a button - so you probably don't want to do that.