第一种方法:
setAdjustsImageWhenHighlighted // default is YES. if YES, image is drawn darker when highlighted(pressed)
UIButton *priceBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [priceBtn setTag:PRICE_BTN_TAG]; [priceBtn setFrame:CGRectMake(DISTANCE_OF_SCREEN_BORDER, 3, 63, 31.5)]; [priceBtn setBackgroundColor:[UIColor clearColor]]; [priceBtn setImage:[UIImage imageNamed:@"sequence_up_pressed.png"] forState:UIControlStateNormal]; [priceBtn addTarget:self action:@selector(priceBtnClicked:) forControlEvents:UIControlEventTouchUpInside]; [priceBtn setAdjustsImageWhenHighlighted:NO];
@property(nonatomic) BOOL reversesTitleShadowWhenHighlighted; // default is NO. if YES, shadow reverses to shift between engrave and emboss appearance
@property(nonatomic) BOOL adjustsImageWhenHighlighted; // default is YES. if YES, image is drawn darker when highlighted(pressed)
@property(nonatomic) BOOL adjustsImageWhenDisabled; // default is YES. if YES, image is drawn lighter when disabled
@property(nonatomic) BOOL showsTouchWhenHighlighted; // default is NO. if YES, show a simple feedback (currently a glow) while highlighted
第二种方法:
本群的Misery-iOS-武汉提到了一个巧妙的方法 正常&高亮用相同的图片
[priceBtn setImage:[UIImage imageNamed:@"sequence_up_pressed.png"] forState:UIControlStateNormal]; [priceBtn setImage:[UIImage imageNamed:@"sequence_up_pressed.png"] forState:UIControlStateHighlighted];
欢迎其他同志们补充