1

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

谢谢

迪伦

4

1 回答 1

0

You can set different images and/or background images based on the UIControlState. For example in case of images:

[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

or in case of background colour, add targets:

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

and in the target method, like buttonpressed:

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

    [button setBackgroundColor:[UIColor blueColor]];
}

and so on for respective states

于 2013-09-28T06:37:29.620 回答