美文网首页
阿里云点播横竖屏

阿里云点播横竖屏

作者: 无极战思 | 来源:发表于2020-06-14 17:48 被阅读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

    相关文章

      网友评论

          本文标题:阿里云点播横竖屏

          本文链接:https://www.haomeiwen.com/subject/mjffxktx.html