swift - Swift 动画删除线 uilabel
问题描述
我正在尝试通过动画制作罢工动画。我能找到的唯一帮助是这个UIFont: 如何为删除线设置动画并匹配字体样式?但它的 Objective-C 我正在尝试这样的结果https://dribbble.com/shots/3167358-Microinteractions-for-to-do-list-app。但无法弄清楚如何为删除线设置动画。
guard let postsText = post?.post else { return }
let attributeString: NSMutableAttributedString = NSMutableAttributedString(string: postsText)
attributeString.addAttribute(NSAttributedString.Key.strikethroughStyle, value: 1, range: NSMakeRange(0, attributeString.length))
postLabel.attributedText = attributeString
解决方案
我创建了一个使用贝塞尔路径创建此效果的库,为删除线设置动画。你可以在这里找到代码:
https://github.com/chrsp/StrikethroughLabel
作为记录,本课程展示了您如何做到这一点:
https://github.com/chrsp/StrikethroughLabel/blob/master/StrikethroughLabel/StrikethroughLabel.swift
推荐阅读
- sqlite - 如何在sqlite导入的csv中设置主键
- gke-networking - gke-1.13 和 gke-1.14 与 Peered VPC 通信的区别
- javascript - 在Javascript中打印对象数组的元素
- java - 无法将文件从服务器上传到另一个
- java - AndroidStudio:“onCreateViewHolder”方法无法从其类中识别我的“.xml”布局文件
- java - 打开键盘时如何调整底页大小?
- java - 卡夫卡消费者并不总是收到消息
- ios - 如何在 Codemagic 中指定目标平台 ios 版本号
- python - Python 3-ValueError:没有足够的值来解包(预期 3,得到 2)
- python - Python从字符串中删除特殊字符不起作用