首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iOS:通过CATransform3DRotate旋转时跳转uiview

iOS:通过CATransform3DRotate旋转时跳转uiview
EN

Stack Overflow用户
提问于 2018-07-17 23:22:51
回答 0查看 104关注 0票数 0

我尝试用自己的锚点旋转一个90度角的uiview (高度和宽度为100)。更改锚点后,我转换我的视图,以便两个更改相互抵消。

当我使用(Double.pi)旋转视图时,它会像预期的那样产生动画效果,但当我更改为(Double.pi/2)时,视图会向上跳跃。

代码语言:javascript
复制
    testView.layer.anchorPoint = CGPoint(x: 0.5, y: 1)
    testView.layer.transform = CATransform3DMakeTranslation(0, -50, 0)

    UIView.animate(withDuration: 2.3, delay: 0, options: .curveLinear, animations: { () -> Void in
        var allTransofrom = self.testView.layer.transform
        var c3d = CATransform3DIdentity
        c3d.m34 = 2.5 / (2000)
        let rot = CATransform3DRotate(c3d, CGFloat(Double.pi/2), 1, 0, 0)
        allTransofrom = CATransform3DConcat(allTransofrom, rot)
        self.testView.layer.transform = allTransofrom
    }, completion: {(finished) in
    } )

完整代码here

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51385107

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档