Created
December 6, 2013 04:29
-
-
Save tomohisa/7818580 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSMutableAttributedString * mutable = [[NSMutableAttributedString alloc] init]; | |
[mutable appendAttributedString:[[NSMutableAttributedString alloc] initWithString:self.user.name attributes:@{NSFontAttributeName: [UIFont boldSystemFontOfSize:12*TOVConstSizeRate]}]]; | |
[mutable appendAttributedString:[[NSMutableAttributedString alloc] initWithString:@" " attributes:@{NSFontAttributeName: [UIFont boldSystemFontOfSize:6*TOVConstSizeRate]}]]; | |
[mutable appendAttributedString:[[NSMutableAttributedString alloc] initWithString:@"(@" attributes:@{NSFontAttributeName: [UIFont boldSystemFontOfSize:11*TOVConstSizeRate]}]]; | |
[mutable appendAttributedString:[[NSMutableAttributedString alloc] initWithString:self.user.screenName attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:11*TOVConstSizeRate]}]]; | |
[mutable appendAttributedString:[[NSMutableAttributedString alloc] initWithString:@")\t" attributes:@{NSFontAttributeName: [UIFont boldSystemFontOfSize:11*TOVConstSizeRate]}]]; | |
[mutable appendAttributedString:[[NSMutableAttributedString alloc] initWithString:[CommonDate getFlexibleDateStringFromDate:self.createdAt] attributes:@{NSFontAttributeName: [UIFont boldSystemFontOfSize:11*TOVConstSizeRate]}]]; | |
[mutable appendAttributedString:[[NSMutableAttributedString alloc] initWithString:@"\n" attributes:@{NSFontAttributeName: [UIFont boldSystemFontOfSize:11*TOVConstSizeRate]}]]; | |
[mutable appendAttributedString:[[NSMutableAttributedString alloc] initWithString:[self.text stringByDecodingHTMLEntities] attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:12*TOVConstSizeRate]}]]; | |
if (self.retweetersStatus) { | |
[mutable appendAttributedString:[[NSMutableAttributedString alloc] initWithString:@"\nretweeted by:" attributes:@{NSFontAttributeName: [UIFont boldSystemFontOfSize:10*TOVConstSizeRate]}]]; | |
[mutable appendAttributedString:[[NSMutableAttributedString alloc] initWithString:self.retweetersStatus.user.name attributes:@{NSFontAttributeName: [UIFont boldSystemFontOfSize:11*TOVConstSizeRate]}]]; | |
[mutable appendAttributedString:[[NSMutableAttributedString alloc] initWithString:@" " attributes:@{NSFontAttributeName: [UIFont boldSystemFontOfSize:6*TOVConstSizeRate]}]]; | |
[mutable appendAttributedString:[[NSMutableAttributedString alloc] initWithString:@"(@" attributes:@{NSFontAttributeName: [UIFont boldSystemFontOfSize:10*TOVConstSizeRate]}]]; | |
[mutable appendAttributedString:[[NSMutableAttributedString alloc] initWithString:self.retweetersStatus.user.screenName attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:10*TOVConstSizeRate]}]]; | |
[mutable appendAttributedString:[[NSMutableAttributedString alloc] initWithString:@")\t" attributes:@{NSFontAttributeName: [UIFont boldSystemFontOfSize:10*TOVConstSizeRate]}]]; | |
[mutable appendAttributedString:[[NSMutableAttributedString alloc] initWithString:[CommonDate getFlexibleDateStringFromDate:self.retweetersStatus.createdAt] attributes:@{NSFontAttributeName: [UIFont boldSystemFontOfSize:10*TOVConstSizeRate]}]]; | |
} | |
[mutable addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:TOV2Data.fontColorRed green:TOV2Data.fontColorGreen blue:TOV2Data.fontColorBlue alpha:1.0] range:NSMakeRange(0, mutable.length)]; | |
NSMutableParagraphStyle *paragraph = [[NSMutableParagraphStyle alloc] init]; | |
paragraph.minimumLineHeight = 12.0f*TOVConstSizeRate; | |
paragraph.maximumLineHeight = 12.0f*TOVConstSizeRate; | |
paragraph.alignment = NSTextAlignmentLeft; | |
paragraph.lineBreakMode = NSLineBreakByCharWrapping; | |
NSTextTab *t = [[NSTextTab alloc] initWithTextAlignment:NSTextAlignmentRight location:width-10 options:nil]; | |
paragraph.tabStops = @[t]; | |
[mutable addAttribute:NSParagraphStyleAttributeName value:paragraph range:NSMakeRange(0, mutable.length)]; | |
textView.attributedText = mutable.copy; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment