我在控制器中有一个包含GMSMapView的子视图-最初它已折叠并且仅占据一部分屏幕-然后用户可以展开它并以全屏模式查看地图。 下面的代码有效,但是动画末尾出现了奇怪的闪烁 这是我的代码:
let screenHeight = screenSize.height
let proportionalHeight = (screenSize.width * 46.0 ) / 75.0
mapViewHeight.constant = !isMapFullscreen ? screenHeight : proportionalHeight
UIView.animate(withDuration: 1.0, delay: 0,
usingSpringWithDamping: 0.9,
initialSpringVelocity: 0,
options: UIViewAnimationOptions.curveEaseInOut,
animations: {
self.view.layoutIfNeeded()
},
completion: { finished in
if finished {
self.isMapFullscreen = !self.isMapFullscreen
}
})
答案 0 :(得分:1)
已经快两年了,可是:
由于此错误尚未解决,因此我们至少可以使用CATransaction来抑制它。这个想法是在完成主动画后禁用动画(错误)。
示例:
CATransaction.begin()
UIView.animate(...,
animations: { ... },
completion: { finished in
if finished {
...
CATransaction.setDisableActions(true)
}
})
CATransaction.commit()