UIButtonのタイトルテキストの色を設定するにはどうすればいいですか? 質問する

UIButtonのタイトルテキストの色を設定するにはどうすればいいですか? 質問する

ボタンのテキストの色を変更してみましたが、まだ白のままです。

isbeauty = UIButton()
isbeauty.setTitle("Buy", forState: UIControlState.Normal)
isbeauty.titleLabel?.textColor = UIColorFromRGB("F21B3F")
isbeauty.titleLabel!.font = UIFont(name: "AppleSDGothicNeo-Thin" , size: 25)
isbeauty.backgroundColor = UIColor.clearColor()
isbeauty.layer.cornerRadius = 5
isbeauty.layer.borderWidth = 1
isbeauty.layer.borderColor = UIColorFromRGB("F21B3F").CGColor
isbeauty.frame = CGRectMake(300, 134, 55, 26)
isbeauty.addTarget(self,action: "first:", forControlEvents: UIControlEvents.TouchUpInside)
self.view.addSubview(isbeauty)

赤、黒、青に変更してみましたが、何も起こりません。

ベストアンサー1

func setTitleColor(_ color: UIColor?, for state: UIControl.State)実際のタイトルテキストを設定するのと同じ方法を使用する必要があります。ドキュメント

isbeauty.setTitleColor(UIColorFromRGB("F21B3F"), for: .normal)

おすすめ記事