在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];
 

 

你可能感兴趣的:(button)