ios - 旋转动画发生时,UIImageView 未保留其中心
问题描述
我有一个 UIImageView,我从带有自动布局约束的 nib 加载。我试图将它旋转 180 度,但是当它旋转时,它没有保持自己的中心位置,因此形成了一个奇怪的旋转路径。我正在通过此代码旋转图像
//let center = self.viewAnimate.center
UIView.animate(withDuration: 1.3, delay: 0.0, options: [.repeat,.curveEaseInOut], animations: {
//self.viewAnimate.center = center
self.viewAnimate.transform = self.viewAnimate.transform.rotated(by: CGFloat(Double.pi))
}, completion: nil)
当我认为我可以强制它保持动画开始之前的中心位置时,注释部分就完成了。我该如何解决这个问题?
解决方案
推荐阅读
- r - 如何在向数据框中添加新列时进行分组
- html - 是否可以将 Wordpress 模板(Semplice)和一些 HTML 和 CSS 页面结合起来?
- javascript - 即使 Token 不为空,JWT 解码也会重新调整为空
- data-science - 从热图中了解相关性
- html - 当第一个卡头有断字而第二个卡头没有时如何对齐 bootstrap-4 卡
- spring - 有没有办法从 ClientRegistration 对象中查找 OAuth2 提供者 ID?
- permissions - 可写文件夹的问题
- python - 使用烧瓶用户登录/身份验证保护页面
- python - 按日期订购活动
- python - 如何检查列表列表中是否存在重复列表?