问题
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