UIButton 设置背景图和标题的陷阱

注意两点就可以了。

1.初始化使用

UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]

 而不是

UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem]

后者之意思就是为你设计号了内容,居然设计好了内容,再想改变内容【比如图】,是不可能的。

 

2.设置图使用

 [button setImage:OKImage forState:UIControlStateNormal]

 而不是使用

[button.imageView setImage:OKImage forState:UIControlStateNormal]

3.设置标题是用

[button setTitle:@"你好" forState:UIControlStateNormal]

 而不是

[button.titleLabel setTitle:@"OK"]

  

 

posted on 2014-01-04 23:20  mix1009  阅读(305)  评论(0)    收藏  举报

导航