开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜