Board logo

标题: 一种启动动画的实现(2) [打印本页]

作者: look_w    时间: 2019-2-19 16:54     标题: 一种启动动画的实现(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




欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) Powered by Discuz! 7.0.0