How to create segment control like IBInspectable properties?

强颜欢笑 提交于 2019-12-11 04:29:19

问题


I want to create custom control like segment control But i'm not able to understand how to create this kind of Segment IBInspectable properties. i mean it's elements increasing according to Segments. as i know there is no support of array in @IBInspectable.


回答1:


You can't create that type of @IBInspectable (yet), but...

You can define a String variable as an @IBInspectable var, and add multiple lines to it. Then have a didSet method split the string into an array which you use internally (for example)...

Something along these lines:

private var internalTextArray: [String]?

@IBInspectable var segments: String = "" {
    didSet {
        internalTextArray = segments.components(separatedBy: "\n")
        // do something with the split-up lines of text
    }
}



回答2:


@IBInspectable properties is backed by user-defined runtime attribute which is not support Segment data type yet. So I believe that Storyboard does not support the feature you want.



来源:https://stackoverflow.com/questions/43075505/how-to-create-segment-control-like-ibinspectable-properties

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!