【发布时间】:2013-08-17 13:00:42
【问题描述】:
目前我有一个导航栏,上面有一个栏按钮,它是在我的故事板中创建的:
我想去掉条形按钮的白色部分,只保留图像。他们有办法做到这一点吗?
当我尝试这段代码时,没有条形按钮:
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn setBackgroundImage:[UIImage imageNamed:@"19-gear.png"] forState:UIControlStateNormal];
UIBarButtonItem *barButton = [[UIBarButtonItem alloc] initWithCustomView:btn];
self.navigationController.navigationBar.topItem.leftBarButtonItem = barButton;
【问题讨论】:
-
显示创建条形按钮项的代码。
-
@rmaddy 我在我的故事板中创建了它。
-
有没有办法将按钮的样式设置为“普通”而不是“边框”?无论如何,这将在代码中完成。
-
@rmaddy 你可以,但我收到警告说“导航项不支持纯文本”
标签: ios image uibarbuttonitem