你可以这样做:
UIView.animate(withDuration: 0.25, delay: 0, options: [.autoreverse, .curveEaseIn, .repeat], animations: {
let transform = CATransform3DIdentity
let rotate = CATransform3DRotate(transform, 45, 1, 1, 0)
self.ex.layer.transform = rotate
}, completion: nil)
对于所有可能的调用,您可以检查这个链接 https://developer.apple.com/documentation/uikit/uiview/1622418-animate
另外,如果你确实需要UIViewPropertyAnimator
, 它有一个类似的初始化 https://developer.apple.com/documentation/uikit/uiviewpropertyanimator/1648367-runningpropertyanimator:
UIViewPropertyAnimator.runningPropertyAnimator(withDuration: 0.25, delay: 0, options: [.autoreverse, .curveEaseIn, .repeat], animations: {
let transform = CATransform3DIdentity
let rotate = CATransform3DRotate(transform, 45, 1, 1, 0)
self.ex.layer.transform = rotate
})