I would like to solve the problem of creating space between titleView and return by emptying the return button characters in the UINavigationController with title=" and setting the search bar such as navigationItem.titleView=UISearchBar().Does anyone know a good solution?
ios swift objective-c uikit uinavigationcontroller
I don't know if it will be solved, but I can reduce the gap by making the return button myself.
(Verified in Xcode 7.2.1/iOS 9.2 simulator environment)
The source code looks like this.
import UIKit
classSecondViewController:UIViewController {
override func viewDidLoad(){
super.viewDidLoad()
// Add Search Bar
let sb = UISearchBar()
navigationItem.titleView=sb
// Create a UIBarButtonItem with a standard image
let img = UIImage(named: "back-image")
navigationItem.leftBarButtonItem=UIBarButtonItem(image:img, style: .Plain, target:self, action:"backMenu")
}
/// Return to previous screen
funcbackMenu(){
dismissViewControllerAnimated(true, completion:nil)
}
}
© 2024 OneMinuteCode. All rights reserved.