<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      iOS 視頻全屏功能 學(xué)習(xí)

      項(xiàng)目中,也寫(xiě)過(guò)類(lèi)似"視頻全屏"的功能, 前一陣子讀到今日頭條 的一篇技術(shù)文章,詳細(xì)介紹三種旋轉(zhuǎn)方法差異優(yōu)劣最終擇取。文章從技術(shù)角度看寫(xiě)的非常好,從用戶(hù)角度看,也用過(guò)多家有視頻功能的app,今日頭條的體驗(yàn)的確很優(yōu)。特別值得學(xué)習(xí)特此參考寫(xiě)了一個(gè)視頻全屏小功能

       實(shí)現(xiàn)方法:配合重寫(xiě)當(dāng)前的ViewController的shouldAutorotate方法,返回NO 并且控制 狀態(tài)欄的展示  然后 通過(guò) animation旋轉(zhuǎn)動(dòng)畫(huà)處理UI相對(duì)布局 

      (1)組織類(lèi)別方法 UINavigationController+Rotation 目的視頻旋轉(zhuǎn) 狀態(tài)欄也要旋轉(zhuǎn)

      //
      //  UINavigationController+Rotation.h
      //  SectionDemo
      //
      //  Created by HF on 17/4/1.
      //  Copyright ? 2017年 HF-Liqun. All rights reserved.
      //
      
      #import <UIKit/UIKit.h>
      
      @interface UINavigationController (Rotation)
      
      @end
      //
      //  UINavigationController+Rotation.m
      //  SectionDemo
      //
      //  Created by HF on 17/4/1.
      //  Copyright ? 2017年 HF-Liqun. All rights reserved.
      //
      
      #import "UINavigationController+Rotation.h"
      
      @implementation UINavigationController (Rotation)
      
      - (BOOL)shouldAutorotate
      {
          return [[self.viewControllers lastObject] shouldAutorotate];
      }
      
      
      - (NSUInteger)supportedInterfaceOrientations
      {
          return [[self.viewControllers lastObject] supportedInterfaceOrientations];
      }
      
      
      - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
          return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
      }
      
      @end

      (2)視頻UI HFMovieView

      //
      //  HFMovieView.h
      //  SectionDemo
      //
      //  Created by HF on 17/4/1.
      //  Copyright ? 2017年 HF-Liqun. All rights reserved.
      //
      
      #import <UIKit/UIKit.h>
      #import "HFPlayerView.h"
      
      typedef NS_ENUM(NSUInteger, MovieViewState) {
          MovieViewStateSmall,
          MovieViewStateAnimating,
          MovieViewStateFullscreen,
      };
      
      @interface HFMovieView : UIView
      
      /**
       視頻播放對(duì)象
       */
      @property (nonatomic, strong)HFPlayerView *videoView;
      
      /**
       記錄小屏?xí)r的parentView
       */
      @property (nonatomic, weak) UIView *movieViewParentView;
      
      /**
       記錄小屏?xí)r的frame
       */
      @property (nonatomic, assign) CGRect movieViewFrame;
      
      @property (nonatomic, assign) MovieViewState state;
      
      
      @end
      //
      //  HFMovieView.m
      //  SectionDemo
      //
      //  Created by HF on 17/4/1.
      //  Copyright ? 2017年 HF-Liqun. All rights reserved.
      //
      
      #import "HFMovieView.h"
      
      @implementation HFMovieView
      
      - (instancetype)initWithFrame:(CGRect)frame
      {
          self = [super initWithFrame:frame];
          if (self) {
              
               //videoView
              [self addSubview:self.videoView];
              
              //others
              UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)];
              [self.videoView addGestureRecognizer:tapGestureRecognizer];
          
          }
          return self;
      }
      
      #pragma mark - event
      
      - (void)handleTapGesture:(UITapGestureRecognizer *)sender
      {
          if (sender.state == UIGestureRecognizerStateEnded)
          {
              if (self.state == MovieViewStateSmall) {
                  [self enterFullscreen];
              }
              else if (self.state == MovieViewStateFullscreen) {
                  [self exitFullscreen];
              }
          }
      }
      
      #pragma mark - private
      
      #pragma mark -- 全屏 animation
      - (void)enterFullscreen {
          
          if (self.state != MovieViewStateSmall) {
              return;
          }
          
          self.state = MovieViewStateAnimating;
          
          /*
           * 記錄進(jìn)入全屏前的parentView和frame
           */
          self.movieViewParentView = self.videoView.superview;
          self.movieViewFrame = self.videoView.frame;
          
          /*
           * movieView移到window上
           */
          CGRect rectInWindow = [self convertRect:self.videoView.bounds toView:[UIApplication sharedApplication].keyWindow];
          [self.videoView removeFromSuperview];
          self.videoView.frame = rectInWindow;
          [[UIApplication sharedApplication].keyWindow addSubview:self.videoView];
          
          /*
           * 執(zhí)行動(dòng)畫(huà)
           */
          [UIView animateWithDuration:0.5 animations:^{
              self.videoView.transform = CGAffineTransformMakeRotation(M_PI_2);
              self.videoView.bounds = CGRectMake(0, 0, CGRectGetHeight(self.videoView.superview.bounds), CGRectGetWidth(self.videoView.superview.bounds));
              self.videoView.center = CGPointMake(CGRectGetMidX(self.videoView.superview.bounds), CGRectGetMidY(self.videoView.superview.bounds));
          } completion:^(BOOL finished) {
              self.state = MovieViewStateFullscreen;
          }];
          
          [self refreshStatusBarOrientation:UIInterfaceOrientationLandscapeRight];
      }
      
      #pragma mark -- 退出全屏 animation
      
      - (void)exitFullscreen
      {
          if (self.state != MovieViewStateFullscreen) {
              return;
          }
          
          self.state = MovieViewStateAnimating;
          
          CGRect frame = [self.movieViewParentView convertRect:self.movieViewFrame toView:[UIApplication sharedApplication].keyWindow];
          
          [UIView animateWithDuration:0.5 animations:^{
              self.videoView.transform = CGAffineTransformIdentity;
              self.videoView.frame = frame;
          } completion:^(BOOL finished) {
              /*
               * movieView回到小屏位置
               */
              [self.videoView removeFromSuperview];
              self.videoView.frame = self.movieViewFrame;
              [self.movieViewParentView addSubview:self.videoView];
              self.state = MovieViewStateSmall;
          }];
          
          [self refreshStatusBarOrientation:UIInterfaceOrientationPortrait];
      }
      
      
      #pragma mark -- 更新?tīng)顟B(tài)欄方向
      
      - (void)refreshStatusBarOrientation:(UIInterfaceOrientation)interfaceOrientation {
          [[UIApplication sharedApplication] setStatusBarOrientation:interfaceOrientation animated:YES];
      }
      
      
      #pragma mark - setter and getter
      
      - (HFPlayerView *)videoView
      {
          if (!_videoView) {
              _videoView = [[HFPlayerView alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
              _videoView.backgroundColor = [UIColor blackColor];
          }
          return _videoView;
      }
      
      
      @end

      (3)視圖控制器

      //
      //  MethodDetailViewController.h
      //  SectionDemo
      //
      //  Created by HF on 17/4/1.
      //  Copyright ? 2017年 HF-Liqun. All rights reserved.
      //
      
      #import <UIKit/UIKit.h>
      #import "HFMovieView.h"
      
      @interface MethodDetailViewController : UIViewController
      
      @property (nonatomic, strong) HFMovieView *moviewView;
      
      @end
      //
      //  MethodDetailViewController.m
      //  SectionDemo
      //
      //  Created by HF on 17/4/1.
      //  Copyright ? 2017年 HF-Liqun. All rights reserved.
      //
      
      #import "MethodDetailViewController.h"
      
      @interface MethodDetailViewController ()
      
      @property (nonatomic, strong) UITableView *tableView;
      @property (nonatomic, strong) UIView *headView;
      
      @end
      
      @implementation MethodDetailViewController
      
      - (void)viewDidLoad {
          [super viewDidLoad];
          
          [self.view addSubview:self.tableView];
          [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
              make.edges.equalTo(self.view);
          }];
          
          self.tableView.tableHeaderView = self.headView;
          [self.headView addSubview:self.moviewView];
      
      }
      
      - (void)didReceiveMemoryWarning {
          [super didReceiveMemoryWarning];
          // Dispose of any resources that can be recreated.
      }
      
      #pragma mark - 旋轉(zhuǎn)配置
      
      - (BOOL)shouldAutorotate {
          return NO;
      }
      
      #pragma mark - setter/getter
      
      - (UITableView *)tableView
      {
          if (!_tableView) {
              _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
              _tableView.backgroundColor = [UIColor clearColor];
              // _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
              
          }
          return  _tableView;
      }
      
      - (UIView *)headView
      {
          if (!_headView) {
              _headView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 200)];;
              _headView.backgroundColor = [UIColor lightGrayColor];
          }
          return _headView;
      }
      
      - (HFMovieView *)moviewView
      {
          if (!_moviewView) {
              _moviewView = [[HFMovieView alloc]initWithFrame:CGRectMake(0, 0,  self.view.frame.size.width, 200)];
              _moviewView.backgroundColor = [UIColor yellowColor];
          }
          return _moviewView;
      }
      @end

      效果圖:

       (4)參考之前 寫(xiě)過(guò)視頻播放的相關(guān)方法 優(yōu)化架構(gòu)分工 

        參考 SectionDemo 

      參考:

      1. https://techblog.toutiao.com/2017/03/28/fullscreen/

      2. iOS AVPlayer 學(xué)習(xí)

      posted on 2017-05-22 17:41  ACM_Someone like you  閱讀(1369)  評(píng)論(0)    收藏  舉報(bào)

      導(dǎo)航

      主站蜘蛛池模板: 884aa四虎影成人精品| 精品国产精品午夜福利| 色综合亚洲一区二区小说| 赫章县| 国产午夜精品福利免费不| 女同亚洲精品一区二区三| 加勒比无码人妻东京热| 午夜激情福利在线免费看| 国产仑乱无码内谢| 性按摩玩人妻hd中文字幕 | 在线免费观看毛片av| 久久精品国产清自在天天线| 国产精品美女乱子伦高| 国产一区精品综亚洲av| 国色精品卡一卡2卡3卡4卡在线| 新河县| 伊人成人在线视频免费| 狠狠色噜噜狠狠狠狠色综合久| 精品国产成人国产在线观看| 年日韩激情国产自偷亚洲| 影音先锋啪啪av资源网站| 红桃视频成人传媒| 国内自拍第一区二区三区| 天天做日日做天天添天天欢公交车| 沧州市| 蜜臀av色欲a片无人一区| 亚洲旡码欧美大片| 亚洲av永久无码精品漫画| 狠狠综合久久av一区二| 久久久久国产精品人妻电影| 中文字幕亚洲精品人妻| 国产精品熟女一区二区不卡 | 99国产精品一区二区蜜臀| 六月丁香婷婷色狠狠久久| 国产精品久久久久7777| 国产suv精品一区二区五| 人妻无码av中文系列久| 女人腿张开让男人桶爽| 亚洲第一狼人成人综合网| 成 人色 网 站 欧美大片在线观看| 日韩熟女熟妇久久精品综合|