更改按钮标签作为开关关闭声音,我想显示一个开关(对象,切换)

时间:2014-08-06 16:03:06

标签: objective-c button audio switch-statement

我想用开关更改按钮。我需要改变什么?  我想显示一个开关(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];
}

1 个答案:

答案 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];