Mismatched colors on UINavigationBar and UISearchBar

Mismatched colors on UINavigationBar and UISearchBar

By : Lindsay Espqiue
Date : November 21 2020, 11:01 PM
wish helps you I combined Joe's code and my own to come up with a working solution for iOS 10.
code :
let rect = CGRect(origin: CGPoint(x: 0, y:0), size: CGSize(width: 1, height: 1))
let context = UIGraphicsGetCurrentContext()!
context.setFillColor(UIColor(red: 86.0/255.0, green: 200.0/255.0, blue: 246.0/255.0, alpha: 1.0).cgColor)
let image = UIGraphicsGetImageFromCurrentImageContext()

//To change Navigation Background colour.
navigationController?.navigationBar.setBackgroundImage(image, for: UIBarPosition.any, barMetrics: UIBarMetrics.default)
navigationController?.navigationBar.shadowImage = UIImage()
navigationController?.navigationBar.isTranslucent = false
navigationController?.navigationBar.barTintColor = UIColor(red: 86.0/255.0, green: 200.0/255.0, blue: 246.0/255.0, alpha: 1.0)

//To change SearchBar Background colour.
self.searchBar.isTranslucent = false
self.searchBar.backgroundImage = image
searchBar.barTintColor = UIColor(red: 86.0/255.0, green: 200.0/255.0, blue: 246.0/255.0, alpha: 1.0)
searchBar.layer.borderColor  = UIColor(red: 86.0/255.0, green: 200.0/255.0, blue: 246.0/255.0, alpha: 1.0).cgColor

Share : facebook icon twitter icon
Replace uinavigationbar by uisearchbar

Replace uinavigationbar by uisearchbar

By : user3798232
Date : March 29 2020, 07:55 AM
this one helps. I want to replace uinavigationbar by uisearchbar in a specific view can I do that ? , Yes, Hide the navigationbar in that view as follows....
code :
            self.navigationController.navigationBarHidden = YES;
UISearchBar in right of UINavigationBar in objective c

UISearchBar in right of UINavigationBar in objective c

By : Shane Kelly
Date : March 29 2020, 07:55 AM
Hope this helps I created an iPad application in which I would like to have my searchBar to be positioned in the right of a navigation bar. , Try this:
code :
UISearchBar *searchBar = [[[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 100, 40)] autorelease];
searchBar.backgroundImage = [[[UIImage alloc] init] autorelease];
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:searchBar] autorelease];
Color of the UISearchBar is not the same as the UINavigationBar

Color of the UISearchBar is not the same as the UINavigationBar

By : Nahuel Ambrosini
Date : March 29 2020, 07:55 AM
will help you So I continued to look for a solution and I partially found one. It turns out that the "Search bar and search display controller" that we can use in Interface Builder was deprecated in iOS 8.0. And I even made a blank app with just one navigation controller and aforementioned search bar and the color of the latter is always out of place.
I didn't find any solution to that exact problem but managed to change my project a bit. Now I'm using UISearchController added programmatically.
code :
let searchController = UISearchController(searchResultsController: nil)
tableView.tableHeaderView = searchController.searchBar
iOS 11 UISearchBar in UINavigationBar

iOS 11 UISearchBar in UINavigationBar

By : Jean.J
Date : March 29 2020, 07:55 AM
Hope this helps I want to place a search bar in the new navigation bar with the new iOS 11 large titles. However, the color of the search bar is automatically applied by iOS and I can't change it. , Now it's what you want...
code :
if #available(iOS 11.0, *) {
            let sc = UISearchController(searchResultsController: nil)
            sc.delegate = self
            let scb = sc.searchBar
            scb.tintColor = UIColor.white
            scb.barTintColor = UIColor.white

            if let textfield = scb.value(forKey: "searchField") as? UITextField {
                textfield.textColor = UIColor.blue
                if let backgroundview = textfield.subviews.first {

                    // Background color
                    backgroundview.backgroundColor = UIColor.white

                    // Rounded corner
                    backgroundview.layer.cornerRadius = 10;
                    backgroundview.clipsToBounds = true;


            if let navigationbar = self.navigationController?.navigationBar {
                navigationbar.barTintColor = UIColor.blue
            navigationItem.searchController = sc
            navigationItem.hidesSearchBarWhenScrolling = false

UISearchBar extends behind UINavigationBar

UISearchBar extends behind UINavigationBar

By : M Campbell
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , I have just found the problem. There was some age-old code in this view controller:
code :
extension MyViewController : UINavigationBarDelegate {
    func position(for bar: UIBarPositioning) -> UIBarPosition {
        return UIBarPosition.topAttached
Related Posts Related Posts :
  • TKChartDataPoint does not conform to expected type Sequence
  • IOS/Swift - Instance member 'app' cannot be used on type ERROR
  • Create show Case view In Tabbar xcode
  • Create IOS App with Cordova on Windows10
  • Get parent process information at runtime on iOS application
  • Destination attribute mapping not showing newly added attribute in xcmodelmappingmodel while Coredata migration
  • How to convert string to NSArray in iOS
  • Converting all Realm Objects to Dictionary at once
  • How to use DACircularProgressView in swift3?
  • Stop Core Data calculation?
  • issue and crash after deletion of last row
  • Multiple UNUserNotifications not firing
  • Drawing a rectangle under text on image Then save
  • auto adjust custom UITableViewCell and Label in it to the text
  • Only use pictures taken through the camera, iOS/Swift
  • UITableView objective-c not populating correctly
  • UNNotification: Custom Sound for LocalNotification is not playing in iOS10
  • Alamofire: How to download zip files sequentially within UITableView
  • iOS Google Tag Manager Integration: How to add multiple containers per App environment?
  • I am getting Exe_Bad_Access(code=1 address=0X38) when I am integrating the CCAvenue Payment Gate way in IOS
  • iOS How to set background image for text in UILabel/UITextView?
  • Notification localization is not working in iOS 10
  • how to show multiple lines in MKAnnotation with autolayout?
  • iOS Provisioning Profile Renewal Process with MDM
  • UITextView check whether text field is empty or not in Objective-C
  • How to open Add Contact form through app
  • Is there a way to recognize, that the app was installed thru firebase dynamic link in didFinishLaunchingWithOptions?
  • iOS - Support ipv4 only API
  • Get IndexPath Value in UICollectionViewCell Class
  • 2d NSArray with enumerated types in objective-c
  • Return the bool statement directly VS using if to return bool
  • Touch ID: Biometry is locked out. Code=-8
  • Values are not updating in my text label from api calling
  • how to manage Height of UITableHeaderView in based on webview content using auto layout
  • viewDidLoad vs ViewWillAppear in IOS
  • Presenting a detail view controller from a map annotation in swift 3?
  • What is industry standard for when to push/pull between core data and remote database
  • Error when moving objects between NSMutableArray
  • Assigning values to class instance from json output
  • Does Facebook SDK support Swift 2.3/3.0?
  • google maps iOS SDK: custom icons to be used as markers
  • Difficulty reading UserDefaults with Fastlane Snapshot
  • Find individual load time of Dynamic Libraries to identify which library consumes more time to load in IOS
  • Can I add local and remote notifications in my iMessage extension?
  • UIImage goes where i tap (But i need it so you can ONLY drag it)
  • How to handle launch options in Swift 3 when a notification is tapped? Getting syntax problems
  • iOS app that collects data from "Accu-Chek Aviva Connect" BG meter. (Bluetooth Low Energy)
  • How to make a Sprite node spin when a user taps the screen? Swift 3
  • React Native (iOS) app loads nicely on wifi; crashes on LTE/cell
  • How to use GADRewardBasedVideoAd
  • Get game request ID / Access Facebook game request notification content
  • Error opening shared document via CloudKit
  • SKPhysicsJointLimit has a elastic behaviour, but i need a strong rope simulation
  • Handing a response in a controller after segueing to another controller
  • Alamofire request gets stuck when entering background?
  • iOS swift: App Transport Security has blocked a cleartext HTTP (http://) resource
  • Full Screen layout for in Xcode 8
  • Provisioning Profile issue after switching to new iPhone in XCode 8
  • how can I center my map on the annotation view only when it is close to the edge of the screen?
  • How can I choose phone number in INSendPaymentIntent
  • shadow
    Privacy Policy - Terms - Contact Us © soohba.com