0
点赞
收藏
分享

微信扫一扫

在view上画一个button,自定义其按下和松开后的样式


button选custom

然后在viewDidLoad()中:

 

 

//普通状态下:

UIImage *buttonImageNormal = [UIImage imageNamed:@"whiteButton.png"];
UIImage *stretchableButtonImageNormal = [buttonImageNormal stretchableImageWithLeftCapWidth:12 topCapHeight:0];
[self.doSomething setBackgroundImage:stretchableButtonImageNormal forState:UIControlStateNormal];
//按下时高亮:
UIImage *buttonImagePressed = [UIImage imageNamed:@"blueButton.png"];
UIImage *stretchableButtonImagePressed = [buttonImagePressed stretchableImageWithLeftCapWidth:12 topCapHeight:0];
[self.doSomething setBackgroundImage:stretchableButtonImagePressed forState:UIControlStateHighlighted];


举报

相关推荐

0 条评论