开发者

UIBarButtonType as a UIButton. Not on a NavigationBar!

开发者 https://www.devze.com 2023-02-13 00:36 出处:网络
I would like to use the better styled UIBarButtonType as a typical UIButton. This is just to use on a view not a navigationBar.

I would like to use the better styled UIBarButtonType as a typical UIButton. This is just to use on a view not a navigationBar.

I don't really want to recreate the button in an image app and apply to the various states. I know h开发者_运维百科ow to do it the other way around so there must be a way.

Please help.


I tried this and it works :

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

don't forget to put a target on your UIBarButtonItem ;)


You cannot do that. UIBarButtonItems are made just for UIToolbar and UINavigationBar. You need to create your own background image. It isn't a big issue, just few lines.

0

精彩评论

暂无评论...
验证码 换一张
取 消