简体   繁体   中英

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.

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...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM