Per gli elementi Bar
[(UIButton *)[[toolbarItems objectAtIndex:1] customView] setImage:[UIImage imageNamed:@"highlight.png"] forState:UIControlStateNormal];
In generale - Supponendo di avere un pulsante
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self
action:@selector(someFunction:)
forControlEvents:UIControlEventTouchDown];
[button setTitle:@"Click here" forState:UIControlStateNormal];
button.frame = CGRectMake(0.0, 0.0, 100.0, 40.0);
[self.view addSubview:button];
è possibile in un qualsiasi punto, chiamare a livello di programmazione di questa funzione:
[button setTitle:@"Look Here" forState:UIControlStateNormal];
o se ti piace avere un'immagine highlight
btnImage = [UIImage imageNamed:@"highlight.png"];
[button setImage:btnImage forState:UIControlStateNormal];
Una semplice alternativa:
Detto questo, è anche possibile impostare il pulsante in questo modo:
- (void)highlightButton:(UIButton *)button {
[button setHighlighted:YES];
}
Grazie per la risposta! L'effetto bagliore bianco nella barra degli strumenti è predefinito nell'SDK di iOS, non ho alcun highlight.png e dovrei crearne uno. Non esiste altro modo per attivare l'effetto bagliore bianco predefinito? – Manni
@Manni Ho appena fatto un highlight.png per te, LOL – PeakJi