swift - 快速将蒙版转换为另一个带有动画的蒙版
问题描述
我想在动画中更改蒙版
但它就像换成另一个没有动画 屏幕记录的面具
我希望它看起来像这样
func creatMask(_ index: Int) -> CALayer {
let layer = CALayer()
let image = [#imageLiteral(resourceName: "bubble_1.png"),#imageLiteral(resourceName: "bubble_2.png"),#imageLiteral(resourceName: "bubble_3.png"),#imageLiteral(resourceName: "bubble_4.png"),#imageLiteral(resourceName: "bubble_5.png")]
layer.contents = image[index].cgImage
layer.contentsScale = image[index].scale
layer.frame = CGRect(x: 0, y: 0, width: 200, height: 200)
return layer
}
@objc func transform() {
UIView.animate(withDuration: 1) {
self.redView.layer.mask = self.creatMask(1)
}
}
}
解决方案
推荐阅读
- scala - Spark写入多个文件
- excel - 基于 Excel 范围更新/更改的自动电子邮件
- python - python selenium.webdriver 返回“在此服务器上找不到请求的文档”的结果
- python - 有没有办法将分散的数据插入到复杂的 3d 网格上?
- android - 向所有群组和用户发送消息 Telegram
- shell - bin/ksh cat 语句未分配给变量
- http - 将多个 toJson 方法合并为一个请求
- python - 为什么 pandas isnull() 有效但 ==None 无效?
- c# - 使用 IEnumerator 时的 Dispose 是什么?
- java - 缓慢的 Swing GUI 启动时间