- (void)viewDidLoad
{
UIImage *buttonImageNormal = [UIImage imageNamed:@"whiteButton.png"];
UIImage *stretchableButtonImageNormal = [buttonImageNormal
stretchableImageWithLeftCapWidth:12
topCapHeight:0];
[doSomethingButton setBackgroundImage:stretchableButtonImageNormal
forState:UIControlStateNormal];
UIImage *buttonImagePressed = [UIImage imageNamed:@"blueButton.png"];
UIImage *stretchableButtonImagePressed = [buttonImagePressed
stretchableImageWithLeftCapWidth:12
topCapHeight:0];
[doSomethingButton setBackgroundImage:stretchableButtonImagePressed
forState:UIControlStateHighlighted];
}
本文介绍如何在iOS开发中使用UIImage的stretchableImage方法为UIButton设置不同状态下的伸缩背景图片,包括正常状态和按下状态。
1561

被折叠的 条评论
为什么被折叠?



