iOS标签未在MPMoviePlayerViewController上正确定位

时间:2014-08-28 17:16:49

标签: ios position uilabel mpmovieplayercontroller

我有一个全屏视频,我想在视图的中心添加一个自定义标签。

所以我做了像

这样的事情
let url = NSBundle.mainBundle().URLForResource("back", withExtension: "mp4")
    let player = MPMoviePlayerViewController(contentURL: url)
    presentMoviePlayerViewControllerAnimated(player)
    player.moviePlayer.repeatMode = MPMovieRepeatMode.One
    player.moviePlayer.controlStyle = MPMovieControlStyle.None
    player.moviePlayer.view.transform = CGAffineTransformConcat(player.moviePlayer.view.transform,
                                                                CGAffineTransformMakeRotation(CGFloat(M_PI/2)))
    player.moviePlayer.shouldAutoplay = true
    player.moviePlayer.prepareToPlay()
    player.moviePlayer.play()

    self.label.text = "Welcome."

    // Enum type, two variations:
    self.label.textAlignment = .Center
    self.label.center = self.view.center
    player.moviePlayer.view.addSubview(self.label)

但结果是我在右上角有标签,而label.frame告诉我(139.0,273.5,42.0,21.0)

我已经尝试过:

self.view.addSubview(self.label)

那么有什么建议吗?

1 个答案:

答案 0 :(得分:0)

如果您希望label位于ViewController视图的中心,请将其添加到该视图中。这将解决您的问题:

self.view.addSubview(self.label)而不是将其添加到player