由于APP要语言本地化,icon下还要有文字描述,导致切图不能带上文字;只好代码去控制了。实现方式如下:
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.backgroundColor = [UIColor clearColor];
//设置图片
UIImage *imageForButton = [UIImage imageNamed:@"icon_search"];
[button setImage:imageForButton forState:UIControlStateNormal];
//设置文字
[button setTitle:LS(@"Search") forState:UIControlStateNormal];
button.titleLabel.font = [UIFont systemFontOfSize:10];