黑马程序员技术交流社区
标题:
NSMutableAttributedString
[打印本页]
作者:
xiaochongzi
时间:
2015-12-1 09:05
标题:
NSMutableAttributedString
NSMutableAttributedString 需求
NSMutableAttributedString的初级学习和进阶
作者:
SimonLo
时间:
2015-12-1 20:21
http://snowyshell.blog.163.com/blog/static/2209140342014475383375/
http://blog.csdn.net/zhangao0086/article/details/7616385
网上找的两篇博客,希望对你有用
作者:
ios学者
时间:
2015-12-8 18:18
1 // initWithString:
2 NSAttributedString *attributedString_str = [[NSAttributedString alloc] initWithString:@"attributedString"];
3 NSLog(@"%@", attributedString_str);
4 // textView.attributedText = attributedString_str;
5
6
7 // initWithAttributedString:
8 NSAttributedString *attributedString_atts = [[NSAttributedString alloc] initWithAttributedString:attributedString_str];
9 NSLog(@"%@", attributedString_atts);
10 // textView.attributedText = attributedString_atts;
11
12
13 // initWithString:attributes:
14 UIColor *backgroundColor = [UIColor blackColor];
15 NSNumber *baseLineOffset = [NSNumber numberWithFloat:20.0];
16 UIColor *foregroundColor = [UIColor whiteColor];
17 NSNumber *kern = [NSNumber numberWithFloat:5.0];
18 NSNumber *ligature = [NSNumber numberWithFloat:3.0];
19 NSURL *linkURL = [NSURL URLWithString:@"http://www.baidu.com"];
20 NSNumber *underline = [NSNumber numberWithInt:NSUnderlineStyleSingle];
21 NSDictionary *attrsDic = @{NSForegroundColorAttributeName: foregroundColor,
22 NSBackgroundColorAttributeName: backgroundColor,
23 NSBaselineOffsetAttributeName: baseLineOffset,
24 NSKernAttributeName: kern,
25 NSLigatureAttributeName: ligature,
26 NSLinkAttributeName: linkURL,
27 NSUnderlineStyleAttributeName: underline
28 };
29 NSAttributedString *attributedString_str_atts = [[NSAttributedString alloc] initWithString:@"http://www.baidu.com" attributes:attrsDic];
30 NSLog(@"%@", attributedString_str_atts);
31 // textView.attributedText = attributedString_str_atts;
32
33
34 // initWithFileURL:options:documentAttributes:error:
35 NSURL *fileURL = nil;
36 fileURL = [[NSBundle mainBundle] URLForResource:@"Dynamic Coloring" withExtension:@"rtf"];
37 NSAttributedString *attributedString_fileURL = [[NSAttributedString alloc] initWithFileURL:fileURL options:@{} documentAttributes:nil error:nil];
38 NSLog(@"%@", attributedString_fileURL);
39 // textView.attributedText = attributedString_fileURL;
40
41
42 // initWithData:options:documentAttributes:error:
43 fileURL = nil;
44 fileURL = [[NSBundle mainBundle] URLForResource:@"View Layout" withExtension:@"rtf"];
45 NSData *data = [[NSData alloc] initWithContentsOfURL:fileURL];
46 NSAttributedString *attributedString_data = [[NSAttributedString alloc] initWithData:data options:@{} documentAttributes:nil error:nil];
47 NSLog(@"%@", attributedString_data);
48 // textView.attributedText = attributedString_data;
49
50
51 // initWithAttributedString:
52 NSMutableAttributedString *mutableAttributedString_attrs = [[NSMutableAttributedString alloc] initWithAttributedString:attributedString_fileURL];
作者:
ios学者
时间:
2015-12-8 21:48
大兄弟,这个行不行?求赐教
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2