hgw*_*tle 6 calayer cgaffinetransform uiviewanimation ios swift
我正在使用以下代码将 CGAffineTransform 动画应用于 UIView:
UIView.animate(withDuration: 0.5, delay: delay, options: [.autoreverse, .repeat], animations: {
elementView.transform = CGAffineTransform(scaleX: 1.0, y: 0.4)
}) { (finished) in
}
Run Code Online (Sandbox Code Playgroud)
UIView 在动画中正确缩放,但我也将 UIView 的角半径设置为完美地环绕视图的顶部和底部。
问题是,当发生缩放动画时,我的 UIView 的角半径被“压扁”了:
如何确保角半径保持完美圆润,同时保持缩放动画?
我认为你最好的选择是改变frame以下属性elementView:
UIView.animate(withDuration: 0.5, delay: delay, options: [.autoreverse, .repeat], animations: {
elementView.frame = CGRect(x: elementView.frame.origin.x, y: elementView.frame.origin.y, width: elementView.frame.size.width, height: elementView.frame.size.height * 0.4)
}) { (finished) in
}
Run Code Online (Sandbox Code Playgroud)
或者如果您使用自动布局:
heightContraint.constant = heightConstraint * 0.4
UIView.animate(withDuration: 0.5, delay: delay, options: [.autoreverse, .repeat], animations: {
elementView.layoutIfNeeded()
}) { (finished) in
}
Run Code Online (Sandbox Code Playgroud)
无论哪种方式,都应该在缩短视野的同时保持角半径。
| 归档时间: |
|
| 查看次数: |
2342 次 |
| 最近记录: |