I have been trying to get around setting navigationitem button's width property but couldn't find a way to get it done what exactly I am looking for.
Following code works fine setting button size what I want and appear nicely but I don't see actually button, its rather only my image. It should appear like button and it has background image!
UIButton *addCommentButton = [UIButton buttonWithType:UIButtonTypeCustom];
[addCommentButton setFrame:CGRectMake(0, 0, 25, 25)];
[addCommentButton addTarget:self action:@selector(addComment) forControlEvents:UIControlEventTouchUpInside];
[addCommentButton setBackgroundImage:[UIImage imageNamed:@"myImage.png"] forState:UIControlStateNormal];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:addCommentButton];
Following code does that, but I can't set button size (25,25)!!
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"myImage.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(addComment)];
I tried setting width explicitly but it does make no difference!
[[self.navigationItem rightBarButtonItem] setWidth] = 25;
Can someone please help me to sort out this issue. Thanks.