且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用Swift将删除线添加到iOS 11中的NSAttributedString

更新时间:2022-11-21 19:49:11

我用它来删除Xcode9/iOS11/Swift4 env中的文本

I use this to strike through a text in Xcode9/iOS11/Swift4 env

  let strokeEffect: [NSAttributedStringKey : Any] = [
        NSAttributedStringKey.strikethroughStyle: NSUnderlineStyle.styleSingle.rawValue,
        NSAttributedStringKey.strikethroughColor: UIColor.red,
    ]

   let strokeString = NSAttributedString(string: "text", attributes: strokeEffect)