UILabelで下線付きのテキストを作成するにはどうすればいいですか? 質問する

UILabelで下線付きのテキストを作成するにはどうすればいいですか? 質問する

で下線付きのテキストを作成するにはどうすればいいですかUILabel?

UILabel私は高さのあるものを作ってみました0.5fテキストの下に配置します。この行ラベルは、アプリをiPhone 4.3そしてiPhone 4.3 シミュレーター、しかし、それはiPhone 5.0 シミュレーター以降。なぜですか?

これどうやってするの?

ベストアンサー1

オブジェクティブC

iOS 6.0 > バージョン

UILabelサポートNSAttributedString

NSMutableAttributedString *attributeString = [[NSMutableAttributedString alloc] initWithString:@"Hello Good Morning"];
[attributeString addAttribute:NSUnderlineStyleAttributeName
                        value:[NSNumber numberWithInt:1]
                        range:(NSRange){0,[attributeString length]}];

迅速

let attributeString: NSMutableAttributedString =  NSMutableAttributedString(string: "Hello Good Morning")
attributeString.addAttribute(NSUnderlineStyleAttributeName, value: 1, range: NSMakeRange(0, attributeString.length))

意味:

- (void)addAttribute:(NSString *)name value:(id)value range:(NSRange)aRange

Parameters List:

名前: 属性名を指定する文字列。属性キーは、別のフレームワークによって提供されることも、ユーザーが定義したカスタムの属性キーにすることもできます。システムが提供する属性キーの場所については、NSAttributedString クラス リファレンスの概要セクションを参照してください。

価値: 名前に関連付けられた属性値。

範囲: 指定された属性/値のペアが適用される文字の範囲。

次のように使用します:

yourLabel.attributedText = [attributeString copy];

iOS 5.1.1 <バージョン

3 party attributed Label以下を表示する必要がありますattributed text:

1) 参照TTT属性ラベルリンク。その最良の第三者attributed Labeldisplay帰属しますtext

2) 参照するOH属性ラベル第三者向けattributed Label

おすすめ記事