Reputation: 1268
It is looks like a very simple question But i do not know where the mistake is. I have an navigation bar i am placing a custom nav bar back button The action is performed through out the "pink" color as shown in the image below
My code is below:
//-------back button start
UIImage *myImage1 = [UIImage imageNamed:@"Back.png"];
UIButton *myButton1 = [UIButton buttonWithType:UIButtonTypeCustom];
[myButton1 setImage:myImage1 forState:UIControlStateNormal];
myButton1.showsTouchWhenHighlighted = YES;
myButton1.frame = CGRectMake(0.0, 3.0, 40,30);
[myButton1 addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithCustomView:myButton1];
self.navigationItem.leftBarButtonItem = leftButton;
//-------back button end
I tried even this way also like "myButton1.frame = CGRectMake(0.0, 3.0, 20,30);"
Even i tried by changing the button width and height also. Then it is decreasing the width of the back button only .
Thanks in advance
Upvotes: 2
Views: 298
Reputation: 31091
You can set your button size as image size.
myButton1.frame = CGRectMake(0.0, 0.0, 30.0,30.0);
And please check that you don't have any shadow and transparency around image.
Upvotes: 1