我想用开关更改按钮。我需要改变什么? 我想显示一个开关(xcode中的对象,切换)
- (void)doButtonSounds:(id)sender
{
[SoundUtils sharedInstance].soundOn = ![SoundUtils sharedInstance].soundOn;
[Flurry logEvent:@"SETTINGS: doButtonSounds"
withParameters:[NSDictionary dictionaryWithObjectsAndKeys:@"SoundOn", [NSNumber numberWithBool:[SoundUtils sharedInstance].soundOn], nil]];
[self refreshView];
}
答案 0 :(得分:0)
在doButtonSounds中添加以下行:
UIButton* currentButton = (UIButton*) sender; // You won't need this probably.
NSString* newText = [SoundUtils sharedInstance].soundOn ? @"ON" : @"OFF";
[currentButton setTitle:newText forState:UIControlStateNormal];