!= 在大多数语言中意味着不相等 但是 =! 在目标 C? 我在下面的代码片段中找到了这一点。
谢谢
- (void) toggleButton: (UIButton *) aButton
{
if ((_isOn = !_isOn))
{
[self setBackgroundImage:BASEGREEN forState:UIControlStateNormal];
[self setBackgroundImage:PUSHGREEN forState:UIControlStateHighlighted];
[self setTitle:@"On" forState:UIControlStateNormal];
[self setTitle:@"On" forState:UIControlStateHighlighted];
}
else
{
[self setBackgroundImage:BASERED forState:UIControlStateNormal];
[self setBackgroundImage:PUSHRED forState:UIControlStateHighlighted];
[self setTitle:@"Off" forState:UIControlStateNormal];
[self setTitle:@"Off" forState:UIControlStateHighlighted];
}
[self relaxButton:self];
}