Bazinga
Bazinga

Reputation: 2466

UIButton highlighted when pressed

I have two UIButtons. I was able to make them highlighted when pressed. :

-(IBAction) button1Pressed:(id)sender {

    [self performSelector:@selector(highlightButton1:) withObject:sender afterDelay:0.0];
}

- (void)highlightButton1:(UIButton *)a { 
    [a setHighlighted:YES];
}

-(IBAction) button2Pressed:(id)sender {

    [self performSelector:@selector(highlightButton2:) withObject:sender afterDelay:0.0];
}

- (void)highlightButton2:(UIButton *)b { 
    [b setHighlighted:YES];
}

I wanted to unhighlight a button when the other button is highlighted. But I can't make it work.

Upvotes: 0

Views: 279

Answers (1)

Michael Dautermann
Michael Dautermann

Reputation: 89559

If you really have your buttons defined as:

IBOutlet NSButton * mode1;
IBOutlet NSButton * mode2;

then you can do:

- (void)highlightButton1:(UIButton *)a { 
    [mode1 setHighlighted:YES];
    [mode2 setHighlited:NO];
}

- (void)highlightButton2:(UIButton *)b { 
    [mode1 setHighlighted:NO];
    [mode2 setHighlited:YES];
}

parameters a & b are ignored in this particular case...

Upvotes: 2

Related Questions