//宣告一個按鈕
@IBOutletweakvar clickButtonImage: UIButton!
//宣告一個按鈕動作
@IBAction func clickButton(sender: AnyObject) {
//當點下去選擇後,變成反選擇,同樣的反選擇點下去後變成選擇
clickButtonImage.selected = !clickButtonImage.selected
clickButtonImage.selected = !clickButtonImage.selected
//執行store_select這個function
store_select()
}
store_select()
}
//設置store_select這個function
func store_select(){
//設置沒選擇時的圖片與被選擇後的圖片 clickButtonImage.setImage(UIImage(named:"ui__fc_n_plus"),forState:UIControlState.Normal)
clickButtonImage.setImage(UIImage(named:"ui__fc_n_minus"),forState:UIControlState.Selected)
func store_select(){
//設置沒選擇時的圖片與被選擇後的圖片 clickButtonImage.setImage(UIImage(named:"ui__fc_n_plus"),forState:UIControlState.Normal)
clickButtonImage.setImage(UIImage(named:"ui__fc_n_minus"),forState:UIControlState.Selected)
}
沒有留言:
張貼留言