Pixate / pixate-freestyle-ios

Pixate Freestyle for iOS
Apache License 2.0
848 stars 134 forks source link

NSAttributedString how to add few styles? #138

Open plandem opened 10 years ago

plandem commented 10 years ago

Well, i'm using attributed string to style complex string - some words bold, some - differ font, but i can't understand how to style it with Pixate?! :(

Is it possible to do something like this?

NSString text = [NSString stringWithFormat:@"Total time\n%@", formatTimeInterval(total_seconds)]; UIFont font_b = [UIFont fontWithName: APP_FONT size:26]; UIFont *font_s = [UIFont systemFontOfSize:14];

NSMutableAttributedString *label = [[NSMutableAttributedString alloc] initWithString:text]; NSRange width = [[label string] rangeOfString:@"\n"];

[label addAttribute:NSFontAttributeName value:font_s range:NSMakeRange(0, width.location)]; [label addAttribute:NSFontAttributeName value:font_b range:NSMakeRange(width.location, [label length] - width.location)];

plandem commented 10 years ago

here i have one attributed string with few styles - each line has own style.