阿里云点播横竖屏

2020-06-14  本文已影响0人  无极战思

demo地址:https://github.com/hanhuitao/aliyun-.git

阿里云点播服务:

阿里云服务的demo没有全屏按钮,需要自己布局,这里是一个完全按播放器需求的现成布局!

最主要的功能涉及到横竖屏:本文通过对view进行rotation操作,横屏时候移除当前view,将该view加到window,view的transform设为90度,整个子view(进度条等)按横屏布局!竖屏时候移除window的view,view的transform设为0度.将该view重新放回到原来的位置!

横竖屏按钮点击事件:

  -(void)fullScreenClicked:(UIButton*)btn
   {
     btn.selected=!btn.selected;
     if(btn.selected)
     {
      [self.contentView removeFromSuperview];
      [UIView animateWithDuration:0.5f animations:^{
        self.contentView.transform = CGAffineTransformMakeRotation(M_PI/2);
        self.contentView.frame =  CGRectMake(0,0, screenWidth,screenHeight);
        self.fullScreenButton.frame=CGRectMake(screenHeight-40,  screenWidth-40,      40,  40);
        [self.contentView addSubview:self.fullScreenButton];
        [[[UIApplication sharedApplication]keyWindow] addSubview:self.contentView];
      }];
   }else
   {
        [UIView animateWithDuration:0.5f animations:^{
        self.contentView.transform = CGAffineTransformMakeRotation(0);
        self.contentView.frame =  CGRectMake(0, 0, screenWidth, 0.56*screenWidth);
        self.fullScreenButton.frame=CGRectMake(screenWidth-40,  0.56*screenWidth-40, 40,  40);
        }];
    }

 }
Pasted Graphic.png
WechatIMG10.jpg
上一篇下一篇

猜你喜欢

热点阅读