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 |