![](/img/trans.png)
[英]Control-drag in Xcode gives outlets, but no action for UIButton. Why?
[英]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.