美文网首页Swift - UI
NSAttributedString.Key及NSMutable

NSAttributedString.Key及NSMutable

作者: 爱玩游戏的iOS菜鸟 | 来源:发表于2020-03-10 17:20 被阅读0次

NSAttributedString.Key类型属性

  • font 字体,UIFont对象
  • paragraphStyle 段落格式,NSParagraphStyle对象
  • foregroundColor 文字颜色,UIColor对象,default:blackColor
  • backgroundColor 背景色,UIColor对象,default:nil
  • kern 字符间隔, float default:0 不生效
  • strikethroughStyle 删除线,Int default:0 no strikethrough
  • underlineStyle 下划线,Int default:0 no underline
  • strokeColor 描绘边颜色 UIColor对象,default:foregroundColor
  • strokeWidth 描边宽度 Float,default:0 no stroke
  • shadow 阴影,NSShadow对象,default:nil no shadow
  • link 链接 NSURL or NSString
  • baselineOffset 基础偏移量,Float <0:向下偏移 >0:其余部分向下偏移
  • underlineColor 下划线颜色,UIColor对象,default nil: foreground color
  • strikethroughColor 删除线颜色,UIColor对象,default nil: foreground color
  • obliqueness 字体倾斜,Float,default 0: no skew 建议:0~1 太多就很丑了
  • expansion 字体扁平化,default 0: no expansion

【注意】阴影设置range无效,作用在整个NSMutableAttributedString

下面四个属性设置看不到效果,原因未知,有知道的朋友可以告知一下

  • verticalGlyphForm 垂直或者水平 Int 0表示水平,1垂直
  • attachment 附属,NSTextAttachment 对象,default nil
  • textEffect 文字效果,NSString,default nil: no text effect
  • ligature 字符连体,Int default:1 0: no ligatures

NSMutableParagraphStyle属性

  • lineSpacing 行间距
  • paragraphSpacing 段间距
  • alignment 文本对齐方式:(左,中,右,两端对齐,自然)
  • firstLineHeadIndent 首行缩进
  • headIndent 整体缩进(首行除外,首行单独控制)
  • tailIndent 尾部缩进 实际效果:竖着显示
  • lineBreakMode UILabel省略号位置 default is byTruncatingTail
  • minimumLineHeight 最低行高 实际效果:不明
  • maximumLineHeight 最大行高 实际效果:不明
  • baseWritingDirection 书写方向 (.natural、.leftToRight、.rightToLeft)
  • lineHeightMultiple 行高倍数 好像是放大lineSpacing 实际效果:很夸张
  • paragraphSpacingBefore 段前间距 实际效果:与paragraphSpacing效果一样
  • hyphenationFactor 连字属性 值分别为0和1 实际效果:不明

相关文章

网友评论

    本文标题:NSAttributedString.Key及NSMutable

    本文链接:https://www.haomeiwen.com/subject/zkkpdhtx.html