を変更するには、結果を取得し、あなたそれはできますか?トリックはcombining dot above文字(U+0307
)です。それを別の色を作成し、完全に私の上にドットと重なるようにベースラインを調整します
let attributes = [
NSFontAttributeName: UIFont.systemFontOfSize(50, weight: UIFontWeightHeavy)
]
let dotAttributes = [
NSFontAttributeName: UIFont.systemFontOfSize(60, weight: UIFontWeightHeavy),
NSForegroundColorAttributeName: UIColor.redColor(),
NSBaselineOffsetAttributeName: -15
]
let attributedString = NSMutableAttributedString(string: "cli\u{307}ck", attributes: attributes)
attributedString.setAttributes(dotAttributes, range: NSMakeRange(3, 1))
textLabel.attributedText = attributedString
結果:
欠点は、あなたがフォントサイズとベースラインを試してみる必要があるということですdotAttributes
でオフセットして、通常のテキストでうまく演奏できるようにしましょう。
「クリック」の「i」が残りの文字よりも別の色を持つ属性付き文字列を作成することを意味しますか? – Sajjon
@Sajjonいいえ、画像の「i」のように「i」の円の色を変更したい – pableiros
NSAttributedStringを使用することは不可能です。または、文字列ベースでも。私はあなたがそのイメージを必要としていると思います。 – Sajjon