我不知道为什么,但我突然收到了这个警告,这是我以前没有得到的:
CoreAnimation:刚度必须大于0。 CoreAnimation:阻尼必须大于或等于0。 CoreAnimation:刚度必须大于0。 CoreAnimation:阻尼必须大于或等于0。
对于我的动画,我使用viewAnimation,这不是来自框架UIKit吗?因为阻尼,刚度是来自layerAnimation,而这是来自框架CoreAnimation。
当我更改约束时,问题就会发生。
这是我的代码:
放大图像:
@IBAction func posterButton(sender: AnyObject) {
// Unhide poster
poster.hidden = false
// Show poster:
for constraint in poster.superview!.constraints {
if constraint.identifier == "EnlargePoster" {
constraint.active = false
let newConstraint = NSLayoutConstraint(item: self.poster, attribute: .Bottom, relatedBy: .Equal, toItem: self.poster.superview!, attribute: .Bottom, multiplier: 1, constant: 0)
newConstraint.identifier = "EnlargePoster"
newConstraint.active = true
UIView.animateWithDuration(1.5, delay: 0, usingSpringWithDamping: 0.0, initialSpringVelocity: 0.0, options: [], animations: {
self.view.layoutIfNeeded()
}, completion: {_void in
// show poster close button
self.hidePosterButton.hidden = false
})
}
}
}缩小图像:
@IBAction func hidePoster(sender: AnyObject) {
// hide poster:
for constraint in poster.superview!.constraints {
if constraint.identifier == "EnlargePoster" {
constraint.active = false
let newConstraint = NSLayoutConstraint(item: self.poster, attribute: .Bottom, relatedBy: .Equal, toItem: self.poster.superview!, attribute: .Bottom, multiplier: 1, constant: -672)
newConstraint.identifier = "EnlargePoster"
newConstraint.active = true
UIView.animateWithDuration(0.6, delay: 0, usingSpringWithDamping: 0.0, initialSpringVelocity: 0.0, options: [], animations: {
self.view.layoutIfNeeded()
}, completion: {_void in
// Hide poster
self.poster.hidden = true
})
}
}发布于 2016-06-16 11:36:05
UIView动画是核心动画的高级包装器.在封面下,系统创建一个或多个CAAnimation对象以实现所请求的动画。
在这种情况下,听起来阻尼参数必须大于0,但这一要求不是由UIKit方法强制执行的--当系统将UIKit动画映射到核心动画时,它会生成一个错误。您得到的信息非常清楚地表明阻尼需要大于0,所以使用大于零的值。
我不知道什么是刚度。它必须是在底层核心动画调用中使用的参数,而不是在UIView动画调用中使用的。我猜当你使用一个>0的阻尼值时,这个错误就会消失。
https://stackoverflow.com/questions/37838559
复制相似问题