繁体   English   中英

UIBarButtonType作为UIButton。 不在导航栏上!

[英]UIBarButtonType as a UIButton. Not on a NavigationBar!

我想用更好的风格UIBarButtonType作为一个典型的UIButton。 这只是一个视图不是的导航栏使用。

我真的不想在图像应用程序中重新创建按钮并将其应用于各种状态。 我知道如何反过来做,所以一定有办法。

请帮忙。

你不能这样做。 UIBarButtonItems仅用于UIToolbar和UINavigationBar。 您需要创建自己的背景图像。 这不是一个大问题,只有几行。

我试过了,它有效:

UIButton *info = [UIButton buttonWithType:UIButtonTypeInfoLight];
UIBarButtonItem *infoBis = [[UIBarButtonItem alloc] initWithCustomView:info];
NSArray *array = [[NSArray alloc] initWithObjects:infoBis, nil];
[tool setItems:array animated:YES]; //tool = UIToolbar

不要忘记在您的UIBarButtonItem上放置目标;)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM