如何将信息按钮添加到UIToolbar

Ran*_*ani 4 objective-c

我需要在工具栏中添加信息按钮.

任何人都可以帮我解决这个问题.

提前致谢.

omz*_*omz 13

您需要创建一个UIButton类型UIButtonTypeInfoLight(或,根据您的工具栏颜色UIButtonTypeInfoDark).然后,您可以使用此按钮作为自定义视图UIBarButtonItem:

UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
UIBarButtonItem *infoButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:infoButton] autorelease];
myToolbar.items = [NSArray arrayWithObjects:infoButtonItem, nil];
Run Code Online (Sandbox Code Playgroud)