开发者知识库
首页
最新
最火
关于
搜索答案
中文繁体
相关内容
NSAttributeString创建各种文字效果
本文转载自
dreamDeveloper
查看原文
2016-11-11
105
test
/
test
/
string
/
string
/
创建
/
创建
/
效果
/
效果
/
attributes
attributes
[objc]
view plain
copy
NSDictionary *attributes =@{
NSForegroundColorAttributeName: [UIColorredColor],
NSFontAttributeName: [UIFontfontWithName:
@"Zapfino"
size:
1
6
.0]
};
NSString *strDisplayText =
@"This is an attributed string.";
NSAttributedString *attributedText = [[NSAttributedStringalloc]
initWithString:strDisplayTextattributes:attributes];
self
.lblInfo
.attributedText= attributedText;
[objc]
view plain
copy
NSDictionary *attributes
1 =@{
NSBackgroundColorAttributeName: [UIColororangeColor],
NSFontAttributeName: [UIFontfontWithName:
@"Zapfino"
size:
2
2
.0],
NSKernAttributeName: @-
1
.0
};
NSString *strDisplayText
1 =
@"Orange Background";
NSAttributedString *attributedText
1 = [[NSAttributedStringalloc]
initWithString:strDisplayText
1attributes:attributes
1];
self
.lblInfo1
.attributedText= attributedText
1;
[objc]
view plain
copy
NSShadow*shadow = [[NSShadow
alloc]init];
shadow
.shadowColor = [UIColorgreenColor];
shadow
.shadowBlurRadius =
5
.0;
shadow
.shadowOffset = CGSizeMake(
1
.0,
1
.0);
NSDictionary *attributes
2 =@{
NSUnderlineStyleAttributeName:
@1,
NSShadowAttributeName: shadow
};
NSString *strDisplayText
2 =
@"Shadow Font";
NSAttributedString *attributedText
2 = [[NSAttributedStringalloc]
initWithString:strDisplayText
2attributes:attributes
2];
self
.lblInfo2
.attributedText= attributedText
2;
[objc]
view plain
copy
NSDictionary*subStrAttribute
1 = @{
NSForegroundColorAttributeName: [UIColorredColor],
NSStrikethroughStyleAttributeName:
@2
};
NSDictionary *subStrAttribute
2 =@{
NSForegroundColorAttributeName: [UIColorgreenColor]
};
NSString *strDisplayText
3 =
@"Red and Green";
NSMutableAttributedString *attributedText
3 = [[NSMutableAttributedStringalloc]
initWithString:strDisplayText
3];
[attributedText
3
setAttributes:subStrAttribute
1range:NSMakeRange(
0,
3)];
[attributedText
3
setAttributes:subStrAttribute
2range:NSMakeRange(
8,
5)];
self
.lblInfo3
.attributedText= attributedText
3;
[objc]
view plain
copy
//段落样式设置
NSMutableParagraphStyle *paragraph = [[NSMutableParagraphStyle
alloc]
init];
paragraph
.alignment = NSTextAlignmentJustified;
paragraph
.firstLineHeadIndent =
2
0
.0;
paragraph
.paragraphSpacingBefore =
1
0
.0;
paragraph
.lineSpacing =
5;
paragraph
.hyphenationFactor =
1
.0;
NSDictionary *attributes
4 =@{
NSForegroundColorAttributeName: [UIColorredColor],
NSParagraphStyleAttributeName: paragraph
};
NSString *strDisplayText
4 =@“iPad inspires creativity and ……”;
NSAttributedString *attributedText
4 = [[NSAttributedStringalloc]
initWithString:
strDisplayText4attributes:attributes
4];
self
.lblInfo4
.attributedText= attributedText
4;
顶
0
×
注意!
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。
闪动文字效果
文字效果总结
拖拽--文字效果
使用NSAttributeString创建样式丰富的文字
怎样取消默认文字效果?
第3章CSS文字效果
Swift - 描边文字效果
制作环绕文字效果
边框文字效果的样式
CSS Gradient文字效果
© 2014-2022 ITdaan.com 联系我们:
×
收藏本文
添加到收藏夹 *