做一个清楚的(transluscent)UIBarButttonItem IOS 5
我想使用下面的代码设置UIBarButtonItem的色调颜色,但是我得到的只是一个黑色的button。 有没有办法做到这一点,而不需要使用自定义图像?
[[UIBarButtonItem appearance] SetTintColor:[UIColor clearColor]]:
用一个button创build一个自定义的UIBarButtonItem
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];
如果你的UIToobar或UINavigationBar是半透明的,条形button会自动变成半透明的。
[[self.navigationController navigationBar] setTranslucent:YES];
AFAIK,你不能让一个单独的酒吧button半透明。