开发者

add images to bar button item of toolbar in iphone

开发者 https://www.devze.com 2023-01-31 13:23 出处:网络
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

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

精彩评论

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