I realised that the color-behaviour of my UIBarButtonItem's (left and right buttons) is not as desired.
If I press and hold the right UIBarButton (see video), then the color changes from light-yellow to gray'isch dark-yellow.
However, I would like a solution that keeps the same light-yellow color, no matter of any button selection, press-and-hold, etc. The button color should always stay the same light-yellow.
How can I achieve this ?
Here is the video done in Simulator: (you can clearly see that click-n-hold causes a color-change. what is the solution to keep the light-yellow color even when press-and-hold ??)
Here is the Code:
@IBOutlet weak var btnCancel: UIBarButtonItem!
@IBOutlet weak var btnApply: UIBarButtonItem!
override func viewDidLoad() {
super.viewDidLoad()
btnCancel.title = "Cancel".localized
btnApply.title = "Apply".localized
navigationItem.title = "Filter".localized
let attributes: [NSAttributedString.Key : Any] = [ .font: UIFont(name: "Avenir-Heavy", size: 14)!, .foregroundColor: UIColor.yellow]
navigationItem.rightBarButtonItem?.setTitleTextAttributes(attributes, for: .normal)
navigationItem.rightBarButtonItem?.setTitleTextAttributes(attributes, for: .selected)
navigationItem.rightBarButtonItem?.setTitleTextAttributes(attributes, for: .highlighted)
navigationItem.rightBarButtonItem?.setTitleTextAttributes(attributes, for: .focused)
}
customView
property instead of using thetitle
of the UIBarButtonItem. Not really sure why you would want that though – Corcyra