UIButton - 关闭或减少“选择/按住”色调

时间:2013-09-28 06:08:55

标签: objective-c uibutton tint

我想要一种方法来减少在iOS 7和6上按住UIButton时所获得的黑暗变化(或作为最后手段关闭)。由于选中按钮上的图像,它看起来很糟糕

由于

迪伦

1 个答案:

答案 0 :(得分:0)

您可以根据UIControlState设置不同的图像和/或背景图像。 例如,在图像的情况下:

[comment_notification setBackgroundImage:[UIImage imageNamed:@"1"] forState:UIControlStateNormal];//Normal state

[comment_notification setBackgroundImage:[UIImage imageNamed:@"2"] forState:UIControlEventTouchUpInside];//pressed and released state

[comment_notification setBackgroundImage:[UIImage imageNamed:@"3"] forState:UIControlEventTouchDown];//pressed state

或在背景颜色的情况下,添加目标:

[loginButton addTarget:self action:@selector(performLogin) forControlEvents:UIControlEventTouchUpInside];
[loginButton addTarget:self action:@selector(loginButtonPressed) forControlEvents:UIControlEventTouchDown];
[loginButton addTarget:self action:@selector(releasedButton:) forControlEvents:UIControlEventTouchUpOutside];

并在目标方法中,如buttonpressed:

- (void) buttonpressed:(UIButton*)button{

    [button setBackgroundColor:[UIColor blueColor]];
}
各州的

等等