首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

一种启动动画的实现(2)

一种启动动画的实现(2)

2.  JJLoginVC.m

    #import "JJLoginVC.h"
    #import <MediaPlayer/MediaPlayer.h>
     
    #define kJJLoginVCScreenWidth           ([UIScreen mainScreen].bounds.size.width)
    #define kJJLoginVCScreenHeight          ([UIScreen mainScreen].bounds.size.height)
     
     
    @interface JJLoginVC ()
     
    @property (nonatomic, strong) MPMoviePlayerController *playerVC; //ios9.0废弃
    @property (nonatomic, strong) UIButton *skipButton;
     
     
    @end
     
    @implementation JJLoginVC
     
    - (void)viewDidLoad {
        [super viewDidLoad];
        self.view.backgroundColor = [UIColor magentaColor];
        
        NSString *urlStr = [[NSBundle mainBundle] pathForResource"login" ofType"mov"];
        NSURL *playURL = [NSURL fileURLWithPath:urlStr];
        self.playerVC = [[MPMoviePlayerController alloc] initWithContentURL:playURL];
        [self.view addSubview:self.playerVC.view];
        
        self.playerVC.controlStyle = MPMovieControlStyleNone;
        [self.playerVC.view setFrame:self.view.frame];
        self.playerVC.repeatMode = MPMovieRepeatModeOne;
        self.playerVC.shouldAutoplay = YES;
        self.playerVC.scalingMode = MPMovieScalingModeAspectFill;
        self.playerVC.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        [self.playerVC play];
        
        UIButton *skipButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [skipButton setTitle"跳过" forState:UIControlStateNormal];
        [skipButton setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
        skipButton.titleLabel.font = [UIFont systemFontOfSize:17.0];
        skipButton.alpha = 0.6;
        [self.view addSubview:skipButton];
        [skipButton sizeToFit];
        skipButton.frame = CGRectMake((kJJLoginVCScreenWidth - skipButton.bounds.size.width) * 0.5,
                                      kJJLoginVCScreenHeight - 50.0,
                                      skipButton.bounds.size.width,
                                      skipButton.bounds.size.height);
        [skipButton addTarget:self actionselector(skipButtonDidClick) forControlEvents:UIControlEventTouchUpInside];
        self.skipButton = skipButton;
    }
     
    # pragma mark - Action/ Notification
     
    - (void)skipButtonDidClick
    {
        [self.playerVC stop];
        [self.playerVC.view removeFromSuperview];
        [self.skipButton removeFromSuperview];
    }
     
    @end
返回列表