UIButton showsTouchWhenHighlighted
A Boolean value that determines whether tapping the button causes it to glow.@property(nonatomic) BOOL showsTouchWhenHighlighted
Discussion of [UIButton showsTouchWhenHighlighted]
If YES, the button glows when tapped; otherwise, it does not. The image and button behavior is not changed by the glow. The default value is NO.
UIButton showsTouchWhenHighlighted example.
barButton.style = UIBarButtonItemStylePlain;
uiButton.showsTouchWhenHighlighted = YES;
Example of [UIButton showsTouchWhenHighlighted].
[myButton setImage:[UIImage imageNamed:@"btn_normal.png"] forState:UIControlStateNormal];
[myButton setImage:[UIImage imageNamed:@"btn_highlighted.png"] forState:UIControlStateHighlighted];
[myButton setImage:[UIImage imageNamed:@"btn_highlighted.png"] forState:UIControlStateSelected];
myButton.showsTouchWhenHighlighted = YES;
[myButton setImage:[UIImage imageNamed:@"btn_highlighted.png"] forState:UIControlStateHighlighted];
[myButton setImage:[UIImage imageNamed:@"btn_highlighted.png"] forState:UIControlStateSelected];
myButton.showsTouchWhenHighlighted = YES;
UIButton showsTouchWhenHighlighted example.
if(sectionNum == 2) {
// create the parent view that will hold 1 or more buttons
UIView* v = [[UIView alloc] initWithFrame:CGRectMake(110.0, 0.0, 100.0, 80.0)];
// create the tweet button
UIButton *tbutt = [UIButton buttonWithType: UIButtonTypeCustom];
// set the image (here with a size of 32 x 32)
tbutt.showsTouchWhenHighlighted = YES;
[tbutt setImage: [UIImage imageNamed: @"TwitterIcon.png"] forState: UIControlStateNormal];
// just set the frame of the button (here 64 x 64)
[tbutt setFrame: CGRectMake(250, -10, 54, 54)];
tbutt.tag = 1;
// this sets up the callback for when the user hits the button
[tbutt addTarget:self action:@selector(tweetButtonPressed:) forControlEvents:UIControlEventTouchDown];
// add the button to the parent view
[v addSubview:tbutt];
// create the parent view that will hold 1 or more buttons
UIView* v = [[UIView alloc] initWithFrame:CGRectMake(110.0, 0.0, 100.0, 80.0)];
// create the tweet button
UIButton *tbutt = [UIButton buttonWithType: UIButtonTypeCustom];
// set the image (here with a size of 32 x 32)
tbutt.showsTouchWhenHighlighted = YES;
[tbutt setImage: [UIImage imageNamed: @"TwitterIcon.png"] forState: UIControlStateNormal];
// just set the frame of the button (here 64 x 64)
[tbutt setFrame: CGRectMake(250, -10, 54, 54)];
tbutt.tag = 1;
// this sets up the callback for when the user hits the button
[tbutt addTarget:self action:@selector(tweetButtonPressed:) forControlEvents:UIControlEventTouchDown];
// add the button to the parent view
[v addSubview:tbutt];
End of UIButton showsTouchWhenHighlighted example article.