我想將我的按鈕的背景圖像設置爲其他圖像,如果我的按鈕被按下。WatchKit backgroundImage按鈕更改
初始圖像打開或關閉。如果按鈕backgroundImage是On,我想將它設置爲Off,如果它關閉,我想將它設置爲On。
但我的按鈕沒有getter。我不能使用
self.button1.backgroundImage
有沒有辦法做到這一點?
我想將我的按鈕的背景圖像設置爲其他圖像,如果我的按鈕被按下。WatchKit backgroundImage按鈕更改
初始圖像打開或關閉。如果按鈕backgroundImage是On,我想將它設置爲Off,如果它關閉,我想將它設置爲On。
但我的按鈕沒有getter。我不能使用
self.button1.backgroundImage
有沒有辦法做到這一點?
這裏有一個簡單的方法,你可以這樣做:
1.定義的ImageView爲你的按鈕
2.define布爾的改變圖像
子視圖當用戶點擊該按鈕:
-(void)btnTap:(id)sender{
if(boolOne){
ImageView.image = [UIImage imageNamed:@"firstImageView.png"];
bool = false;
}else{
ImageView.image = [UIImage imageNamed:@"secondImageView.png"];
bool = true;
}
}
WatchKit在控件上沒有任何屬性。有價值:布爾不發送者:AnyObject。