2017-05-13 5 views
0

のようにUIBarButtonItemの下にラベルを追加する基本的に私はUIBarButtonを使用して、これを達成したい:UITabBarItem

enter image description here

私はsetTitleを使用してみましたが、私はこのようなものに終わる:

enter image description here

答えて

0

をあなたのカスタムナビゲーションバーを作成する - あなたのviewcontrollerの上にUIViewを追加し、それの左隅にUIButtonを追加します。ボタンの下にラベルを付けます。

0

UIBarButtonItemでカスタムビューを使用して行うことができます。このようなもの。

スウィフト

let image = UIImage.init(named: "image_name") 
let button = UIButton.init(type: .custom) 
button.frame = CGRect.init(x: 0, y: 0, width: 100, height: 40) 
button.setBackgroundImage(image, for: .normal) 
button.setTitle("title", for: .normal) 
let barButtonItem = UIBarButtonItem.init(customView: button) 
関連する問題