Change title color of navigation bar in MFMailComposeViewController in iOS 12 not working [duplicate]

/// UINavigationBar let navBarAppearance = UINavigationBar.appearance() navBarAppearance.barTintColor = .red navBarAppearance.tintColor = .white navBarAppearance.backgroundColor = .red navBarAppearance.titleTextAttributes = [ .foregroundColor: UIColor.white, .font: UIFont.systemFontSize ] navBarAppearance.largeTitleTextAttributes = [ .foregroundColor: UIColor.white, .font: UIFont.smallSystemFontSize ] let barButtonAppearance = UIBarButtonItem.appearance() barButtonAppearance.setTitleTextAttributes([.font: UIFont.systemFontSize], for: .normal) navBarAppearance.isTranslucent = false if #available(iOS 13.0, *) { let appearance = UINavigationBarAppearance() appearance.configureWithOpaqueBackground() appearance.backgroundColor = navBarAppearance.backgroundColor … Read more

Create NavBar programmatically with Button and Title Swift

Updated for Swift 5 Create a navigation item instance and set title and right/left buttons to it. After navigation item is configured add it to the navigation bar. let navBar = UINavigationBar(frame: CGRect(x: 0, y: 0, width: view.frame.size.width, height: 44)) view.addSubview(navBar) let navItem = UINavigationItem(title: “SomeTitle”) let doneItem = UIBarButtonItem(barButtonSystemItem: .done, target: nil, action: #selector(selectorName:)) … Read more

NSFontAttributeName has changed to String

The UIFont constructor is returning an optional (UIFont?) which you must unwrap to use. Add ! if you’re sure you have a valid font name: Swift 4.2: navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.font: UIFont(name: “HelveticaNeue-Light”, size: 19)!] Swift 4: navigationController?.navigationBar.titleTextAttributes = [NSAttributedStringKey.font: UIFont(name: “HelveticaNeue-Light”, size: 19)!] Swift 3: navigationController?.navigationBar.titleTextAttributes = [NSFontAttributeName: UIFont(name: “HelveticaNeue-Light”, size: 19)!] Note: If you … Read more

How to hide the navigation bar and toolbar as scroll down? Swift (like myBridge app)

Try this simple approach: Tested in Swift 3 func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) { if(velocity.y>0) { //Code will work without the animation block.I am using animation block incase if you want to set any delay to it. UIView.animate(withDuration: 2.5, delay: 0, options: UIViewAnimationOptions(), animations: { self.navigationController?.setNavigationBarHidden(true, animated: true) self.navigationController?.setToolbarHidden(true, animated: true) … Read more

UINavigationBar UIBarButtonItems much larger click area than required

This is the only solution I found. Create a container of the custom button: //Create a container for the button UIView *buttonContainer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 55, 44)]; //Create a smaller button UIButton *closeButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 55, 25)]; [closeButton setTitle:@”Cancel” forState:UIControlStateNormal]; //center the title closeButton.titleEdgeInsets = UIEdgeInsetsMake(23, 0, 0, 0); [buttonContainer … Read more

How to set multi line Large title in navigation bar? ( New feature of iOS 11)

Based in @krunal answer, this is working for me: extension UIViewController { func setupNavigationMultilineTitle() { guard let navigationBar = self.navigationController?.navigationBar else { return } for sview in navigationBar.subviews { for ssview in sview.subviews { guard let label = ssview as? UILabel else { break } if label.text == self.title { label.numberOfLines = 0 label.lineBreakMode = … Read more

Real time blur effect for Navigation Bar

Apple has introduced new classes UIVisualEffectView and more to add translucency and blur effect on views from iOS 8.0 release. Here how you can use it to add a blur effect to navigation bar or any other UIView: Swift 5 func addBlurEffect() { let bounds = self.navigationController?.navigationBar.bounds let visualEffectView = UIVisualEffectView(effect: UIBlurEffect(style: .light)) visualEffectView.frame = … Read more

Remove Navigationbar’s bottom border iOS7

That does not work on iOS7 with navigation translucent or not… A paste from Apple documentation; Description The shadow image to be used for the navigation bar. The default value is nil, which corresponds to the default shadow image. When non-nil, this property represents a custom shadow image to show instead of the default. For … Read more