1
在我的UITextView中,我希望某些NSRanges
左右同樣縮進,並以特定顏色突出顯示。我通過修改NSMutableAttributedStrings
並設置textView.attributedText
來實現此目的。爲了獲得左/右縮進,我使用NSMutableParagraphStyle
- 但是,這是刪除突出顯示(NSBackgroundColor
)。我怎樣才能得到它,突出顯示從一開始就開始,即使是headIndent
。UITextView:保持左/右段落縮進的背景顏色
// padding
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.headIndent = 5.0;
paragraphStyle.firstLineHeadIndent = 5.0;
paragraphStyle.tailIndent = -5.0;
NSDictionary *referenceAttributes = @{NSForegroundColorAttributeName: [UIColor lightGrayColor], NSBackgroundColorAttributeName: [UIColor brownColor], NSFontAttributeName: [UIFont fontWithName:@"HelveticaNeue-Bold" size: 14], NSParagraphStyleAttributeName: paragraphStyle};
嗨阿希什 - 這將無法滿足,但是我在第一行上市,因爲這將適用於填充的要求到我的TextView中的所有NSRanges,而不僅僅是我感興趣的展示 – SimplyLearning 2014-12-05 01:37:48