UIButton外观变化披露为何呢?怎么避免呢?

时间:2013-10-23 18:29:22

标签: ios uiappearance appearance customizing

因此,当我自定义按钮时,我会放置一个这样的背景图像:

- (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

2 个答案:

答案 0 :(得分:0)

stretchableImageWithLeftCapWidth:topCapHeight:deprecated

改为使用resizableImageWithCapInsets:

答案 1 :(得分:0)

我复制了你的代码,图片对我来说很好。 我唯一需要补充的是一个框架。

当没有背景图像时,tintColor似乎只能工作。