我試圖將右側欄按鈕項的字體顏色更改爲紫色,但仍顯示爲白色。我諮詢了question和question。我該如何解決?更改UIBarButtonItem的字體顏色
代碼
let sortButton = UIButton(frame: CGRect(x: 0, y: 0, width: 34, height: 15))
sortButton.setTitle("SORT", for: .normal)
sortButton.titleLabel?.tintColor = UIColor.myMusicPurple
sortButton.tintColor = UIColor.myMusicPurple
navigationItem.rightBarButtonItem = UIBarButtonItem(customView: sortButton)
navigationItem.rightBarButtonItem?.tintColor = UIColor.myMusicPurple