I'm making login screen with video background But after I added my background all the Main.storyboard code gets behind my video (video goes on top) how can I bring video to back of my view?
Code :
var moviePlayer : MPMoviePlayerController?
let myPlayerView = UIView(frame: self.view.bounds)
myPlayerView.backgroundColor = UIColor.clearColor()
view.addSubview(myPlayerView)
var urlpath = NSBundle.mainBundle().pathForResource("video", ofType: "m4v")
let url:NSURL = NSURL.fileURLWithPath(urlpath!)!
let myPlayer = AVPlayer(URL: url)
myPlayer.play()
let avLayer = AVPlayerLayer(player: myPlayer)
avLayer.frame = myPlayerView.bounds
myPlayerView.layer.addSublayer(avLayer)
Simply add this at the appropriate place. eg viewWillAppear
.
myPlayerView.superview?.sendSubviewToBack(myPlayerView)
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.