2016-10-03 4 views
1

私はUINavigationBarの高さを変更するので、バーのボタン項目を上に移動したいと思います。setBackgroundVerticalPositionAdjustmentが機能しない

は、私が使用:

[[UIBarButtonItem appearance] setBackgroundVerticalPositionAdjustment:-20.0 forBarMetrics:UIBarMetricsDefault]; 

それは、カスタムイメージで作成した私のUIBarButtonのために動作しますが、他の1含まれるテキストのために動作しません。私は、次のように宣言されたテキスト付きのUIBarButtonを上に移動したい:

UIBarButtonItem *bbiDone = [[UIBarButtonItem alloc] initWithTitle:@"Готово" style:UIBarButtonItemStyleDone target:nil action:nil]; 

これを移動するには?

答えて

0
//creat a custom view 

let customView = UIView(frame: CGRect(x: 0, y: 0, width: 40, height: 40)) 

//creat a button 

let nvButton = UIButton(frame: CGRect(x: 0, y: -40, width: 40, height: 40)) 

//add button to custom view's subview 

customView.addSubView(nvButton) 

let nvRightItem = UIBarButtonItem(customView: customView) 
self.navigationItem.rightBarButtonItem = nvRightItem 
関連する問題