add images to bar button item of toolbar in iphone
i want to add images to bar button item of toolbar i tried with xib an开发者_JAVA百科d code both but image shows up as white patch can anybody suggest what am i doing wrong or which way should i proceed
set the button type as custom.
Try like this
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:[UIImage imageNamed:@"myImage.png"] forState:UIControlStateNormal];
[button addTarget:self action:@selector(blah) forControlEvents:UIControlEventTouchUpInside];
[button setFrame:CGRectMake(0, 0, 32, 32)];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
All the best.
got a link which shows working like what Warrior suggests
http://www.iphonedevsdk.com/forum/iphone-sdk-development/33286-color-image-uibarbuttonitem-uitoolbar.html
精彩评论