iPad Video with Transparency

后端 未结 5 1722
一生所求
一生所求 2020-12-15 05:11

is it possible to have a QuickTime video with alpha layer (transparency) play on top of a static dynamic background UIView (i.e. a view that changes occasionall

5条回答
  •  时光取名叫无心
    2020-12-15 05:43

    You could have a normal video and reduce the alpha of the presenting view. This can be done using an AVPlayer and AVPlayerLayer by adding the AVPlayerLayer to a UIView and setting the alpha of the UIView. Something like:

    self.player = [[AVPlayer alloc] initWithURL:url];
    self.playerLayer = [AVPlayerLayer playerLayerWithPlayer:self.player];
    self.playerLayer.frame = view.bounds;
    ...etc...
    self.playerView.alpha = 0.3;
    [self.playerView.layer addSublayer:self.playerLayer];
    

    I haven't tried this with the alpha channel in the video itself, but AVPlayerLayer should work for that as well.

提交回复
热议问题