をNSAttributedString私は(NSAttributedString
を使用して)いくつかのテキストからなるUITextView
内のカスタマイズ可能なラインを描きたいUITextView内の線を引く -
は、ここで私は
NSString *unicodeStr = [NSString stringWithFormat:@"%C%C%C", 0x00A0, 0x0009, 0x00A0]; //nbsp, tab, nbsp
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:unicodeStr];
NSRange strRange = NSMakeRange(0, str.length);
NSMutableParagraphStyle *const tabStyle = [[NSMutableParagraphStyle alloc] init];
tabStyle.headIndent = 16; //padding on left and right edges
tabStyle.firstLineHeadIndent = 16;
tabStyle.tailIndent = -16;
NSTextTab *listTab = [[NSTextTab alloc] initWithTextAlignment:NSTextAlignmentCenter location:40 options:@{}]; //this is how long I want the line to be
tabStyle.tabStops = @[listTab];
[str addAttribute:NSParagraphStyleAttributeName value:tabStyle range:strRange];
[str addAttribute:NSStrikethroughStyleAttributeName value:[NSNumber numberWithInt:2] range:strRange];
しかし、何があっ値Iを試みたものですタブの停止位置(この場合は40)とtailIndent(ここでは-16)を指定すると、行はheadIndentを尊重し、UITextViewの幅全体(もちろんheadIndentを引いた値)に渡ります。
EDIT - 正しいユニコード文字を使用していないため、問題があると確信しています(論理的な選択肢ですが)。これにより誰かにヒントが与えられる場合、2番目のnbspの後、つまり末尾にスペースを追加すると、タブは1つのタブの長さに制限されます
テキストをどのように表示するかの例を挙げることはできますか? –
私はhrタグ(水平ルール)を実装しようとしています。それらは、htmlの – lostInTransit