Constraint changes the size of the UIView(view1) that is present when rotating the screen in swift.
However, the size of the AVPlayerLayer that you add to the UIView does not automatically change.
// Some of the following sources:
// Generate View.
let videoPlayerView = AVPlayerView (frame:view1.bound)
// Make the layer of the UIView AVPlayerLayer.
letlayer=videoPlayerView.layer as!AVPlayerLayer
layer.videoGravity=AVLayerVideoGravity.resizeAspect
layer.player=videoPlayer
// add layers
view1.layer.addSublayer(layer)
I would like to change the layer of the above source when UIview(view1) changes.When rotating the screen, click
override var shouldAutorotate:Bool{}
override var supportedInterfaceOrients:UIInterfaceOrientationMask{}
I think it can be handled by , but how can I change the size of the AVPlayerLayer that I added in addSubLayer?
Please let me know if you know.
swift
With the above source, isn't the layer
property of AVPlayerView
tied to videoPlayerView
?
Therefore, instead of taking out only the layers and not addSubLayer
, create and apply NSLayoutConstraint
to view1
honestly and view1
to AVPode>view1
in InterfaceBuilder
I think that would be better.)
© 2024 OneMinuteCode. All rights reserved.