【问题标题】:Animate UIImageView start from rounded topRight corner and end with Rectangle动画 UIImageView 从圆角右上角开始并以矩形结束
【发布时间】:2019-05-14 07:51:57
【问题描述】:

我正在尝试为我的 ImageView 设置动画,它应该从小圆圈中出现

像这样:

起始尺寸

y = startFrame.origin.y + startFrame.size.height - 10

height = 10 , width = 10

仅右上角

结束帧

原来的矩形

ImageView 内容不应该缩小或扩大,它的内容应该是 看起来像上面的截图。

在 iOS 中可以吗?

【问题讨论】:

  • 添加您目前尝试过的代码。

标签: ios swift uiview uiviewanimation uiviewpropertyanimator


【解决方案1】:

在此处查看此解决方案,它适用于 iOS 11 及更高版本

if #available(iOS 11, *) {

        roundedView.layer.maskedCorners = [.layerMaxXMinYCorner]
        self.roundedView.layer.cornerRadius = 20

        UIView.animate(withDuration: 2, animations: {
            self.roundedView.layer.cornerRadius = 0
        }, completion: nil )

    }

这里也是参考: https://useyourloaf.com/blog/masked-and-animated-corners/

【讨论】:

    猜你喜欢
    • 2021-09-26
    • 2020-08-15
    • 1970-01-01
    • 2018-03-01
    • 2015-08-12
    • 2015-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多