White color when pressing UIBar Button Item

I created a custom panel item using the following code.

UIImage* image3 = [UIImage imageNamed:@" iphone-btn-next@2x.png "]; 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 works fine, but the problem is that when I press the button, I see a white color in the center of the button (see screenshot). Can someone suggest me a way to get rid of this?

enter image description here

+4
source share
2 answers

This must be a response to the recording.

Delete row

 [someButton setShowsTouchWhenHighlighted:YES]; 

Try it than

 UIImage* image3 = [UIImage imageNamed:@" iphone-btn-next@2x.png "]; 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; 
+2
source

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. 
+4
source

Source: https://habr.com/ru/post/1484547/


All Articles