簡體   English   中英

我不能同時在情節提要中將標題和圖像同時設置到導航欄上的右側欄項目嗎?

[英]Cann't I set title and Image to the right bar item on navigation bar at the same time in storyboard?

我想將右鍵按鈕設置為:

在此處輸入圖片說明

它具有標題和下方圖像。

但是在情節提要中,我無法做到這一點:

在此處輸入圖片說明

我只能設置標題和圖像之一,如果設置圖像,則不能設置標題,如果設置標題,則不能設置圖像。

我試過使用UIButton和Button Bar Item來做,得到相同的結果。

一些朋友知道該怎么辦?

您只需將拖曳UIButton添加到storyBoard中的rightBarItem即可。 並根據您的需要自定義該按鈕。

添加UIButton后檢查View層次結構。

在此處輸入圖片說明

您可以嘗試將自定義視圖添加到欄按鈕項

var RightView = UIView(frame: CGRectMake(0, 0, 100, 44))
// you can add in RightView, your title in uilable and your image in imageview  
var RightBarButton = UIBarButtonItem(customView: RightView)
self.navigationItem.rightBarButtonItem = RightBarButton

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM