xcode 6 IB_DESIGNABLE- not loading resources from bundle in Interface builder

前端 未结 6 1160
难免孤独
难免孤独 2020-12-02 17:12

I am trying to make a custom control that updates live in Interface Builder using the new IB_DESIGNABLE option described here.

- (void)drawRect:(CGRect)rect
         


        
6条回答
  •  不知归路
    2020-12-02 18:06

    IN SWIFT 3.0 the code of @rickster has changed to:

    // DYNAMIC BUNDLE DEFINITION FOR DESIGNABLE CLASS
    let theBundle : Bundle = Bundle(for: type(of: self))
    
    // OR ALTERNATEVLY BY PROVDING THE CONCRETE NAME OF DESIGNABLE CLASS
    let theBundle : Bundle = Bundle(for: RH_DesignableView.self)
    
    // AND THEN SUCCESSFULLY YOU CAN LOAD THE RESSOURCE
    let theImage  : UIImage? = UIImage(named: "Logo", in: theBundle, compatibleWith: nil)
    

提交回复
热议问题