我可以在我的视图中显示黑色风格的 UIBarButtonItem 而没有下面的 UIToolBar 吗?
UIToolBar 总是有一种边框,我希望系统 UIBarButtonItem 为黑色,就像黑色标准取消按钮一样,但不是 UIToolBar
我该怎么做?
Thanks
有一个厚颜无耻的黑客可以帮助你解决这个问题。
您想使用样式设置为的 UISegmentedControlUISegmentedControlStyleBar
并且只有一件物品。您还需要setMomentary
是 - 使其表现得像一个按钮:
UISegmentedControl *myCustomButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Hello",nil]];
[myCustomButton setSegmentedControlStyle:UISegmentedControlStyleBar];
[myCustomButton setTintColor:[UIColor blackColor]];
[myCustomButton setMomentary:YES];
[self.view addSubview:myCustomButton];
这将为您提供一个看起来像 UIBarButtonItem 的按钮,您可以将其添加到普通视图中,就像它是一个按钮一样。您还可以添加目标和操作。 :)
这就是你得到的:类似这样的东西:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)