【发布时间】:2015-03-25 12:11:58
【问题描述】:
我有这个按钮,其中背景颜色为白色,图像色调为 x 色。选择后,我希望交换颜色 - bg 是 x(我可以轻松完成),但图像色调始终为灰色(或我设置的颜色的较暗版本)。怎么改?
UIImage *image = [UIImage imageNamed:@"House"];
image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[self setImage:image forState:UIControlStateNormal];
self.imageView.contentMode = UIViewContentModeScaleAspectFit;
//
- (void)highlight {
[super highlight];
[UIView animateWithDuration:HIGHLIGHT_ANIMATION_TIME animations:^{
self.tintColor = [UIColor whiteColor];
}];
}
- (void)unhighlight {
[super unhighlight];
[UIView animateWithDuration:HIGHLIGHT_ANIMATION_TIME animations:^{
self.tintColor = self.colour;
}];
}
【问题讨论】:
标签: ios uibutton uiimage highlight tint