美文网首页
swift3.0迁移到Swift4.0的坑

swift3.0迁移到Swift4.0的坑

作者: 上善若水jf | 来源:发表于2018-05-30 09:34 被阅读30次

swift3.0迁移到Swift4.0的坑

1、Swift4中使用富文本报NSForegroundColorAttributeName、NSFontAttributeName等报错问题,原来发现之前的富文本被弃用了,采用了新的方式来代替,详情请看API,

例如:

1NSForegroundColorAttributeName被 NSAttributedStringKey.foregroundColor代替

NSFontAttributeName被 NSAttributedStringKey.font代替

  @available(iOS 6.0, *)

    public static let font: NSAttributedStringKey // UIFont, default Helvetica(Neue) 12

    @available(iOS 6.0, *)

    public static let paragraphStyle: NSAttributedStringKey // NSParagraphStyle, default defaultParagraphStyle

    @available(iOS 6.0, *)

    public static let foregroundColor: NSAttributedStringKey // UIColor, default blackColor

    @available(iOS 6.0, *)

    public static let backgroundColor: NSAttributedStringKey // UIColor, default nil: no background

    @available(iOS 6.0, *)

    public static let ligature: NSAttributedStringKey // NSNumber containing integer, default 1: default ligatures, 0: no ligatures

    @available(iOS 6.0, *)

    public static let kern: NSAttributedStringKey // NSNumber containing floating point value, in points; amount to modify default kerning. 0 means kerning is disabled.

    @available(iOS 6.0, *)

    public static let strikethroughStyle: NSAttributedStringKey // NSNumber containing integer, default 0: no strikethrough

    @available(iOS 6.0, *)

    public static let underlineStyle: NSAttributedStringKey // NSNumber containing integer, default 0: no underline

    @available(iOS 6.0, *)

    public static let strokeColor: NSAttributedStringKey // UIColor, default nil: same as foreground color

    @available(iOS 6.0, *)

    public static let strokeWidth: NSAttributedStringKey // NSNumber containing floating point value, in percent of font point size, default 0: no stroke; positive for stroke alone, negative for stroke and fill (a typical value for outlined text would be 3.0)

    @available(iOS 6.0, *)

    public static let shadow: NSAttributedStringKey // NSShadow, default nil: no shadow

    @available(iOS 7.0, *)

    public static let textEffect: NSAttributedStringKey // NSString, default nil: no text effect

    @available(iOS 7.0, *)

    public static let attachment: NSAttributedStringKey // NSTextAttachment, default nil

    @available(iOS 7.0, *)

    public static let link: NSAttributedStringKey // NSURL (preferred) or NSString

    @available(iOS 7.0, *)

    public static let baselineOffset: NSAttributedStringKey // NSNumber containing floating point value, in points; offset from baseline, default 0

    @available(iOS 7.0, *)

    public static let underlineColor: NSAttributedStringKey // UIColor, default nil: same as foreground color

    @available(iOS 7.0, *)

    public static let strikethroughColor: NSAttributedStringKey // UIColor, default nil: same as foreground color

    @available(iOS 7.0, *)

    public static let obliqueness: NSAttributedStringKey // NSNumber containing floating point value; skew to be applied to glyphs, default 0: no skew

    @available(iOS 7.0, *)

    public static let expansion: NSAttributedStringKey // NSNumber containing floating point value; log of expansion factor to be applied to glyphs, default 0: no expansion

    @available(iOS 7.0, *)

    public static let writingDirection: NSAttributedStringKey // NSArray of NSNumbers representing the nested levels of writing direction overrides as defined by Unicode LRE, RLE, LRO, and RLO characters.  The control characters can be obtained by masking NSWritingDirection and NSWritingDirectionFormatType values.  LRE: NSWritingDirectionLeftToRight|NSWritingDirectionEmbedding, RLE: NSWritingDirectionRightToLeft|NSWritingDirectionEmbedding, LRO: NSWritingDirectionLeftToRight|NSWritingDirectionOverride, RLO: NSWritingDirectionRightToLeft|NSWritingDirectionOverride,

    @available(iOS 6.0, *)

    public static let verticalGlyphForm: NSAttributedStringKey // An NSNumber containing an integer value.  0 means horizontal text.  1 indicates vertical text.  If not specified, it could follow higher-level vertical orientation settings.  Currently on iOS, it's always horizontal.  The behavior for any other value is undefined.

未完待续。。。。。。

2、宏的修改

'__FILE__' 修改为 '#file'

'__FUNCTION__' 修改为 '#function'

'__LINE__' 修改为 '#line'

相关文章

  • swift3.0迁移到Swift4.0的坑

    swift3.0迁移到Swift4.0的坑 1、Swift4中使用富文本报NSForegroundColorAtt...

  • Swift学习

    刚温习完Swift3.0没多久,Swift4.0就出来了。期待新的开始。

  • iOS 属性修饰词和权限控制词

    Swift 权限控制词 概述 swift3.0中,新增了fileprivate和open权限。swift4.0中,...

  • Swift4.0 之KVC赋值模型数据

    嗯,没错 KVC 赋值操作 之前好好的swift3.0 赋值操作 所有的key都在swift4.0 变得找不到,...

  • 使用 protocol 优雅处理 API

    最近在迁移到 Swift3.0 过程中,为了逐步将 AFNetworking 转移到 Alamofire 上,对于...

  • Swift2.3迁移到Swift3.0

    记录自己项目Swift2.3迁移到Swift3.0的一些难处理的点,和遇到的坑。 一般的整体迁移的话,就看其他的博...

  • Swift那些事儿

    本人小白,欢迎各位大佬补充指点swift3.0到swift4.0变化总结:(工作中一直更新) private修饰在...

  • siwft3.0转4.0开发中遇到的坑

    我们以斗鱼APP为例,总结swift3.0以及swift4.0转换过程中遇到的问题。 一、方法重写问题 1、swi...

  • swift基础版本

    swift4.0已经出现,为了巩固以前的知识,先上一版基础版本 下文是根据swift3.0的一本书挑拣后总结的,所...

  • swift3.0 --> swift4.0

    获取字符串子串 Swift 3.0中 的写法 Swift 4.0中 的写法 相关方法: 字符串相关警告: 警告:'...

网友评论

      本文标题:swift3.0迁移到Swift4.0的坑

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