I have created a custom UISegment Control
@IBDesignable class CardsSegmentedControl: UIControl {
private var labels = [UILabel]()
var thumbView = UIView()
var items: [String] = ["Saved Cards", "Add Card"] {
didSet {
setupLabels()
}
}
var selectedIndex : Int = 0 {
didSet {
displayNewSelectedIndex()
}
}
....
}
Now I wish to change the value of the variable selectedIndex in the viewController where I am adding this custom segment control in.
I guess it is a problem of how to access/change variables from another class.
I tried to create a class func which would set the value of the selectedIndex but I cannot get it to access the selectedIndex variable either.
Still pretty new to Swift so please bear with me.
selectedIndexusing the init function and then use it to change the value elsewhere as well?