iOS 选项器
var optionView :SelectionControl?
var titles :Array<String>?
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
// self.singleSelection()
self.mutilSelection()
}
func singleSelection(){
titles = ["赞成","反对","弃权"]
optionView = SelectionControl(titles: titles!,selectedIndexs: [0],selectionType: SelectionType.SingleSelectionType)
optionView!.delegate = self
optionView!.translatesAutoresizingMaskIntoConstraints = false ;
self.view .addSubview(optionView!);
}
func mutilSelection(){
titles = ["赞成","反对","弃权"]
optionView = SelectionControl(titles: titles!,selectedIndexs: [0],selectionType: SelectionType.MutilSelectionType)
optionView!.delegate = self
optionView!.translatesAutoresizingMaskIntoConstraints = false ;
self.view .addSubview(optionView!);
}
// delegate - SelectionControlDelegate
func selectionControl(selectionControl: SelectionControl, didSelectedOptions selecedIndexs: Array<Int>?) {
print("\(selecedIndexs)")
}