Reputation: 511
I created a custom bar button item using the code below.
UIImage* image3 = [UIImage imageNamed:@"[email protected]"];
CGRect frameimg = CGRectMake(0, 0,57,44);
UIButton *someButton = [[UIButton alloc] initWithFrame:frameimg];
[someButton setBackgroundImage:image3 forState:UIControlStateNormal];
[someButton setBackgroundImage:image3 forState:UIControlStateHighlighted];
[someButton addTarget:self action:@selector(flipView)
forControlEvents:UIControlEventTouchUpInside];
[someButton setShowsTouchWhenHighlighted:YES];
UIBarButtonItem *mailbutton =[[UIBarButtonItem alloc] initWithCustomView:someButton];
self.navigationItem.rightBarButtonItem=mailbutton;
and it's working fine, but the problem is that when I tap the button , I can see the white color in the center of the button (see screenshot). Can someone suggest to me the way to get rid of that?
Upvotes: 4
Views: 126
Reputation: 151
This Should be Write Answer
Remove Line
[someButton setShowsTouchWhenHighlighted:YES];
Try This than
UIImage* image3 = [UIImage imageNamed:@"[email protected]"];
CGRect frameimg = CGRectMake(0, 0,57,44);
UIButton *someButton = [[UIButton alloc] initWithFrame:frameimg];
[someButton setBackgroundImage:image3 forState:UIControlStateNormal];
[someButton setBackgroundImage:image3 forState:UIControlStateHighlighted];
[someButton addTarget:self action:@selector(flipView)
forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *mailbutton =[[UIBarButtonItem alloc] initWithCustomView:someButton];
self.navigationItem.rightBarButtonItem=mailbutton;
Upvotes: 2
Reputation: 7287
Remove this line of code:
[someButton setShowsTouchWhenHighlighted:YES];
According to the documentation
showsTouchWhenHighlighted => A Boolean value that determines whether tapping the button causes it to glow.
Upvotes: 4