Make a clear(transluscent) UIBarButttonItem IOS 5

时光总嘲笑我的痴心妄想 提交于 2019-12-09 02:15:36

create a custom UIBarButtonItem with a button

UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:buttonImage forState:UIControlStateNormal];

//set the frame of the button to the size of the image (see note below)
button.frame = CGRectMake(0, 0, 24, 24);
button.backgroundColor=[UIColor clearColor];    
//create a UIBarButtonItem with the button as a custom view
UIBarButtonItem *customBarItem = [[UIBarButtonItem alloc] initWithCustomView:button];

If your UIToobar or UINavigationBar is translucent, bar buttons automatically become translucent.

[[self.navigationController navigationBar] setTranslucent:YES];

AFAIK, You can't make a bar button alone translucent.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!