2011-03-29 41 views
2

我應該用YES和NO自定義UISwitch,而不是ON和OFF,我該怎麼辦?我不知道做它的代碼。UISwitch自定義

+0

沒有公共的API來對'UISwitch'進行這種修改。如果您想要,請[提交增強請求](http://bugreport.apple.com)。 – 2011-03-29 18:05:52

+0

試試這個 - http://www.catamount.com/blog/?p=1063另外,可能重複這個:所以,看看:http://stackoverflow.com/questions/981061/change-label-of -uiswitch – 2011-03-29 17:42:08

+0

我做了一個自定義的UISwitch。查看它在這裏,它是免費的任何用法:http://xcodenoobies.blogspot.com/2013/04/free-custom-uiswitch-flexible-colors.html – GeneCode 2013-04-08 03:58:24

回答

3

該文檔不顯示用於更改UISwitch樣式的屬性,我一直使用UISlider實現此功能的方式,並且您只能通過代碼設置屬性(至少是高級屬性) 。對於「是」和「否」就可以使圖像設置滑塊的左側和右側,併爲過渡效果,你可以使用普通的動畫功能

[UIView animationWithDuration:0.1f animation^(void){ 
    //code here 
}completion(BOOL finished){ 
    // set the picture here so that you don't see a squished imaged get enlarged 
}]; 

我不知道屬性關閉我的頭頂,所以你將不得不玩弄它,它可能是UISlider.layer.property所以一旦你鍵入第二個.然後一個列表應該出現,你可以滾動找到什麼符合你在找什麼,但不要引用我,我不完全確定這一點。