Initialize the searchbar like this
let searchBar = UISearchBar(frame: CGRect(x: 20, y: 0, width: UIScreen.main.bounds.width-40, height: 40))
//Change x,y,width,height according to your need
Hope this will help you
Create a custom title view (UIView) & add into your navigation bar titleview. In your custom title view, you should override intrinsicContentSize method with UILayoutFittingExpandedSize.
As like Objective C:
- (CGSize)intrinsicContentSize {
return UILayoutFittingExpandedSize;
}
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.