I wan't to reproduce Live Photo zoom effect with AVPlayerLayer
. For this purpose I use VideoView
:
class VideoView: UIView {
override class var layerClass: AnyClass {
return AVPlayerLayer.self
}
var playerLayer: AVPlayerLayer {
return layer as! AVPlayerLayer
}
var player: AVPlayer? {
get {
return playerLayer.player
}
set {
playerLayer.player = newValue
}
}
}
The problem is, that whenever I try to change transform
property of the view or of the layer during the video playback, nothing changes. But the changes are applied later after the playback finishes.
Animation example:
func zoomIn() {
UIView.animate(
withDuration: 0.2,
delay: 0,
options: .allowAnimatedContent,
animations: {
self.transform = .init(scaleX: 1.1, y: 1.1)
},
completion: { _ in
})
}
似乎AVPlayerLayer
忽略许多CALayer
属性,缩放VideoView
的唯一方法是更改其frame
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.