I have created a custom navigation controller subclassing UINavigationController
. now when i increase the size of navigation bar then the back button also slides down. Then how to adjust the y-axis of back button.
self.navigationBar.frame = CGRect(x:0, y: 20, width: self.view.frame.size.width, height: 64.0)
I am able to adjust the y axis of title by below code
self.navigationBar.setTitleVerticalPositionAdjustment(-30, for: .default)
Try - (void)setBackButtonTitlePositionAdjustment:(UIOffset)adjustment forBarMetrics:(UIBarMetrics)barMetrics; - (void)setBackButtonBackgroundVerticalPositionAdjustment:(CGFloat)adjustment forBarMetrics:(UIBarMetrics)barMetrics;
This works in Swift 3
self.navigationController?.navigationBar.frame = CGRect(x: 0, y: 20, width: self.view.bounds.size.width, height: 100)
self.navigationController?.navigationBar.barTintColor = UIColor.yellow
self.title = "My Title"
self.navigationController?.navigationBar.setTitleVerticalPositionAdjustment(-30, for: .default)
let button = UIBarButtonItem(title: "myButton", style: .done, target: self, action: #selector(myViewController.myFunc))
self.navigationItem.leftBarButtonItem = button
self.navigationItem.leftBarButtonItem?.setTitlePositionAdjustment(.init(horizontal: 0, vertical: -30), for: .default)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.