Is there a way for Interface Builder to render IBDesignable views which don't override drawRect:

前端 未结 8 601
不知归路
不知归路 2020-12-02 03:45

I very rarely override drawRect in my UIView subclasses, usually preferring to set layer.contents with pre-rendering images and often employing multiple sublaye

8条回答
  •  日久生厌
    2020-12-02 04:36

    You do not have to use drawRect, instead you can create your custom interface in a xib file, load it in initWithCoder and initWithFrame and it will be live rendering in IB after adding IBDesignable. Check this short tutorial: https://www.youtube.com/watch?v=L97MdpaF3Xg

提交回复
热议问题