-(void) attributeStrings{
NSString* plainStr = [zNSAttributedStringObj string];
NSString* searchWord = @"\n *";
NSRange range = NSMakeRange(0,[plainStr length]);
NSRange target;
while ( target.location != NSNotFound ) {
target = [plainStr rangeOfString:searchWord options:NSLiteralSearch range:range];
NSDictionary *stringAttributes3 = @{ NSForegroundColorAttributeName : [NSColor blueColor]};
if (target.location != NSNotFound) {
[zNSAttributedStringObj setAttributes:stringAttributes3 range:target];
NSInteger from = range.location + [searchWord length];
NSInteger end = [plainStr length] - from;
range = NSMakeRange(from, end);
}
}
}
//searchWordをNsRegularExpressionとNSDictionaryのNSArrayにでもすれば、まとめて色付けできるかな?
//いまのところ実行速度は期待していない。。。
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme