2013-10-23 30 views
0

所以,當我定製我的按鈕,我把這樣一個背景圖片:爲什麼UIButton外觀變更披露?如何避免它?

- (void) styleUIButtons { 
    UIImage *buttonNormalBg = [[UIImage imageNamed:@"button_normal" ] stretchableImageWithLeftCapWidth:0 topCapHeight:0]; 
    UIImage *buttonSelectedBgb = [[UIImage imageNamed:@"button_selected" ] stretchableImageWithLeftCapWidth:0 topCapHeight:0]; 

    id appereance = [UIButton appearance]; 

    [appereance setTintColor:self.mainNavigationBarTextColor]; 
    [appereance setBackgroundImage:buttonNormalBg forState:UIControlStateNormal]; 
    [appereance setBackgroundImage:buttonSelectedBgb forState:UIControlStateHighlighted]; 
} 

但表的變化,一條線路披露指標可怕。爲什麼發生這種情況?我該如何避免它?我是否錯誤地自定義按鈕? enter image description here

回答

0

我複製了你的代碼,圖像對我來說工作正常。 我唯一需要添加的是一個框架。

tintColor只有在沒有背景圖像時才起作用。