How to set default values for IBInspectable in Objective-C?

前端 未结 5 928
面向向阳花
面向向阳花 2021-01-30 16:15

I know default values of IBInspectable-properties can be set as:

@IBInspectable var propertyName:propertyType = defaultValue in Swift. But how do I achieve

5条回答
  •  旧巷少年郎
    2021-01-30 16:23

    Why don't use use the macro such as:

    #if TARGET_INTERFACE_BUILDER   
    // .....IB only specific code when being rendered in IB 
    #endif 
    

    ???

    The prepareForInterfaceBuilder selector may also help you to implement IB specific code.

    More info about those 2 points here:
    https://developer.apple.com/library/ios/recipes/xcode_help-IB_objects_media/chapters/CreatingaLiveViewofaCustomObject.html

提交回复
热议问题