あなたが好きな属性文字列何かを使用して、ボタンの帰属タイトルを設定することができ、
let attributedTitle = NSAttributedString(string: "Click Here",
attributes: [NSForegroundColorAttributeName : UIColor.blueColor()])
button.setAttributedTitle(attributedTitle, forState: .Normal)
あなたが特定のテキストや文字列の一部のために複数の色、フォント、サイズを設定することができます。
別の例として、
attributedTitle = NSMutableAttributedString(string: @"Click Here", attributes: [NSFontAttributeName:UIFont(name: "Georgia", size: 18.0)!])
attributedTitle.addAttribute(NSForegroundColorAttributeName, value: UIColor.redColor(), range: NSRange(location:2,length:4))
button.setAttributedTitle(attributedTitle, forState: .Normal)
だから、あなたはNSRange
を使用して場所を指定することができ、異なる色やフォントを指定した範囲の属性を設定することができます!
属性付き文字列で 'setAttributedTitle'を試してみましたか? – Lion
@KetanParmar帰属文字列の意味は? –
'NSAttributedString'は1つの文字列で異なるサイズ/テキスト/フォント/色を持つことができます。それを作成する方法を試してください – Tj3n