Created a custom bar button with underlined text
You can also add different attributes to make your text customised
You can also add different attributes to make your text customised
let font = UIFont.systemFont(ofSize: CGFloat(15.0))
let attributesForTitleText = [
NSAttributedString.Key.foregroundColor: UIColor.orange,
NSAttributedString.Key.font: font,
NSAttributedString.Key.underlineStyle : NSUnderlineStyle.single.rawValue
] as [NSAttributedString.Key : Any]
let pageTitleButton = UIBarButtonItem(title: pageTitleText, style: UIBarButtonItem.Style.plain, target: self, action: nil)
pageTitleButton.setTitleTextAttributes(attributesForTitleText, for: UIControl.State.normal)
pageTitleButton.setTitleTextAttributes(attributesForTitleText, for: UIControl.State.highlighted)
leftBarButtonArray.append(pageTitleButton)
navigationItem.leftBarButtonItems = leftBarButtonArray
Comments
Post a Comment