2
This commit is contained in:
@@ -56,6 +56,7 @@
|
|||||||
04791FFC2ED71D17004E8522 /* UIColor+Extension.m in Sources */ = {isa = PBXBuildFile; fileRef = 04FC95E42EB220B5007BD342 /* UIColor+Extension.m */; };
|
04791FFC2ED71D17004E8522 /* UIColor+Extension.m in Sources */ = {isa = PBXBuildFile; fileRef = 04FC95E42EB220B5007BD342 /* UIColor+Extension.m */; };
|
||||||
04791FFF2ED830FA004E8522 /* KBKeyboardMaskView.m in Sources */ = {isa = PBXBuildFile; fileRef = 04791FFE2ED830FA004E8522 /* KBKeyboardMaskView.m */; };
|
04791FFF2ED830FA004E8522 /* KBKeyboardMaskView.m in Sources */ = {isa = PBXBuildFile; fileRef = 04791FFE2ED830FA004E8522 /* KBKeyboardMaskView.m */; };
|
||||||
047920072ED86ABC004E8522 /* kb_guide_keyboard.gif in Resources */ = {isa = PBXBuildFile; fileRef = 047920062ED86ABC004E8522 /* kb_guide_keyboard.gif */; };
|
047920072ED86ABC004E8522 /* kb_guide_keyboard.gif in Resources */ = {isa = PBXBuildFile; fileRef = 047920062ED86ABC004E8522 /* kb_guide_keyboard.gif */; };
|
||||||
|
0479200B2ED87CEE004E8522 /* permiss_video.mp4 in Resources */ = {isa = PBXBuildFile; fileRef = 0479200A2ED87CEE004E8522 /* permiss_video.mp4 */; };
|
||||||
047C650D2EBC8A840035E841 /* KBPanModalView.m in Sources */ = {isa = PBXBuildFile; fileRef = 047C650C2EBC8A840035E841 /* KBPanModalView.m */; };
|
047C650D2EBC8A840035E841 /* KBPanModalView.m in Sources */ = {isa = PBXBuildFile; fileRef = 047C650C2EBC8A840035E841 /* KBPanModalView.m */; };
|
||||||
047C65102EBCA8DD0035E841 /* HomeRankContentVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 047C650F2EBCA8DD0035E841 /* HomeRankContentVC.m */; };
|
047C65102EBCA8DD0035E841 /* HomeRankContentVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 047C650F2EBCA8DD0035E841 /* HomeRankContentVC.m */; };
|
||||||
047C65502EBCBA9E0035E841 /* KBShopVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 047C654F2EBCBA9E0035E841 /* KBShopVC.m */; };
|
047C65502EBCBA9E0035E841 /* KBShopVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 047C654F2EBCBA9E0035E841 /* KBShopVC.m */; };
|
||||||
@@ -270,6 +271,7 @@
|
|||||||
04791FFD2ED830FA004E8522 /* KBKeyboardMaskView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBKeyboardMaskView.h; sourceTree = "<group>"; };
|
04791FFD2ED830FA004E8522 /* KBKeyboardMaskView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBKeyboardMaskView.h; sourceTree = "<group>"; };
|
||||||
04791FFE2ED830FA004E8522 /* KBKeyboardMaskView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBKeyboardMaskView.m; sourceTree = "<group>"; };
|
04791FFE2ED830FA004E8522 /* KBKeyboardMaskView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBKeyboardMaskView.m; sourceTree = "<group>"; };
|
||||||
047920062ED86ABC004E8522 /* kb_guide_keyboard.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = kb_guide_keyboard.gif; sourceTree = "<group>"; };
|
047920062ED86ABC004E8522 /* kb_guide_keyboard.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = kb_guide_keyboard.gif; sourceTree = "<group>"; };
|
||||||
|
0479200A2ED87CEE004E8522 /* permiss_video.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; path = permiss_video.mp4; sourceTree = "<group>"; };
|
||||||
047C650B2EBC8A840035E841 /* KBPanModalView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBPanModalView.h; sourceTree = "<group>"; };
|
047C650B2EBC8A840035E841 /* KBPanModalView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBPanModalView.h; sourceTree = "<group>"; };
|
||||||
047C650C2EBC8A840035E841 /* KBPanModalView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBPanModalView.m; sourceTree = "<group>"; };
|
047C650C2EBC8A840035E841 /* KBPanModalView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBPanModalView.m; sourceTree = "<group>"; };
|
||||||
047C650E2EBCA8DD0035E841 /* HomeRankContentVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HomeRankContentVC.h; sourceTree = "<group>"; };
|
047C650E2EBCA8DD0035E841 /* HomeRankContentVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HomeRankContentVC.h; sourceTree = "<group>"; };
|
||||||
@@ -627,6 +629,7 @@
|
|||||||
047C652C2EBCAAAC0035E841 /* Resource */ = {
|
047C652C2EBCAAAC0035E841 /* Resource */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
0479200A2ED87CEE004E8522 /* permiss_video.mp4 */,
|
||||||
047920062ED86ABC004E8522 /* kb_guide_keyboard.gif */,
|
047920062ED86ABC004E8522 /* kb_guide_keyboard.gif */,
|
||||||
04286A122ECDEBF900CE730C /* KBSkinIconMap.strings */,
|
04286A122ECDEBF900CE730C /* KBSkinIconMap.strings */,
|
||||||
04286A0E2ECDA71B00CE730C /* 001.zip */,
|
04286A0E2ECDA71B00CE730C /* 001.zip */,
|
||||||
@@ -1464,6 +1467,7 @@
|
|||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
04286A0F2ECDA71B00CE730C /* 001.zip in Resources */,
|
04286A0F2ECDA71B00CE730C /* 001.zip in Resources */,
|
||||||
|
0479200B2ED87CEE004E8522 /* permiss_video.mp4 in Resources */,
|
||||||
04C6EABA2EAF86530089C901 /* Assets.xcassets in Resources */,
|
04C6EABA2EAF86530089C901 /* Assets.xcassets in Resources */,
|
||||||
04A9FE212EB893F10020DB6D /* Localizable.strings in Resources */,
|
04A9FE212EB893F10020DB6D /* Localizable.strings in Resources */,
|
||||||
047920072ED86ABC004E8522 /* kb_guide_keyboard.gif in Resources */,
|
047920072ED86ABC004E8522 /* kb_guide_keyboard.gif in Resources */,
|
||||||
|
|||||||
BIN
keyBoard/Class/Resource/permiss_video.mp4
Normal file
BIN
keyBoard/Class/Resource/permiss_video.mp4
Normal file
Binary file not shown.
@@ -6,11 +6,11 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import "KBPermissionViewController.h"
|
#import "KBPermissionViewController.h"
|
||||||
|
#import <AVFoundation/AVFoundation.h>
|
||||||
|
|
||||||
@interface KBPermissionViewController ()
|
@interface KBPermissionViewController ()
|
||||||
@property (nonatomic, strong) UILabel *titleLabel; // 标题
|
@property (nonatomic, strong) UILabel *titleLabel; // 标题
|
||||||
@property (nonatomic, strong) UILabel *tipsLabel; // 步骤提示
|
@property (nonatomic, strong) UILabel *tipsLabel; // 步骤提示
|
||||||
@property (nonatomic, strong) UIView *cardView; // 中部卡片
|
|
||||||
@property (nonatomic, strong) UIButton *openButton; // 去设置
|
@property (nonatomic, strong) UIButton *openButton; // 去设置
|
||||||
@property (nonatomic, strong) UIButton *closeButton; // 去设置
|
@property (nonatomic, strong) UIButton *closeButton; // 去设置
|
||||||
|
|
||||||
@@ -19,6 +19,10 @@
|
|||||||
|
|
||||||
@property (nonatomic, strong) UIImageView *bgImageView;
|
@property (nonatomic, strong) UIImageView *bgImageView;
|
||||||
|
|
||||||
|
// 权限引导视频播放器(循环播放,不提供暂停交互)
|
||||||
|
@property (nonatomic, strong) AVPlayer *kb_permPlayer;
|
||||||
|
@property (nonatomic, strong) AVPlayerLayer *kb_permPlayerLayer;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation KBPermissionViewController
|
@implementation KBPermissionViewController
|
||||||
@@ -32,7 +36,7 @@
|
|||||||
[self.view addSubview:self.closeButton];
|
[self.view addSubview:self.closeButton];
|
||||||
[self.view addSubview:self.titleLabel];
|
[self.view addSubview:self.titleLabel];
|
||||||
[self.view addSubview:self.tipsLabel];
|
[self.view addSubview:self.tipsLabel];
|
||||||
[self.view addSubview:self.cardView];
|
// [self.view addSubview:self.videoContainerView];
|
||||||
[self.view addSubview:self.openButton];
|
[self.view addSubview:self.openButton];
|
||||||
[self.view addSubview:self.helpLabel];
|
[self.view addSubview:self.helpLabel];
|
||||||
|
|
||||||
@@ -66,11 +70,13 @@
|
|||||||
make.left.equalTo(self.titleLabel);
|
make.left.equalTo(self.titleLabel);
|
||||||
}];
|
}];
|
||||||
|
|
||||||
[self.cardView mas_makeConstraints:^(MASConstraintMaker *make) {
|
// 视频容器:左右距离 view 16,顶部距离 tipsLabel 30,底部距离按钮 36
|
||||||
make.bottom.equalTo(self.openButton.mas_top).offset(-36);
|
// [self.videoContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
make.left.right.equalTo(self.view).inset(56);
|
// make.top.equalTo(self.tipsLabel.mas_bottom).offset(30);
|
||||||
make.top.equalTo(self.tipsLabel.mas_bottom).offset(36);
|
// make.left.equalTo(self.view).offset(16);
|
||||||
}];
|
// make.right.equalTo(self.view).offset(-16);
|
||||||
|
// make.bottom.equalTo(self.openButton.mas_top).offset(-36);
|
||||||
|
// }];
|
||||||
|
|
||||||
[self.openButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
[self.openButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
make.bottom.equalTo(self.view).offset(-KB_SAFE_BOTTOM-20);
|
make.bottom.equalTo(self.view).offset(-KB_SAFE_BOTTOM-20);
|
||||||
@@ -86,6 +92,30 @@
|
|||||||
// }];
|
// }];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)viewWillAppear:(BOOL)animated {
|
||||||
|
[super viewWillAppear:animated];
|
||||||
|
// 进入页面时自动开始播放
|
||||||
|
[self kb_setupPermissionVideoPlayer];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)viewDidDisappear:(BOOL)animated {
|
||||||
|
[super viewDidDisappear:animated];
|
||||||
|
// 页面离开时停止播放,避免声音继续在其他界面播放
|
||||||
|
[self.kb_permPlayer pause];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)viewDidLayoutSubviews {
|
||||||
|
[super viewDidLayoutSubviews];
|
||||||
|
if (!self.kb_permPlayerLayer) { return; }
|
||||||
|
// 直接铺满整个视图区域,由 videoGravity 负责等比缩放
|
||||||
|
self.kb_permPlayerLayer.frame = CGRectMake(25, CGRectGetMaxY(self.tipsLabel.frame) + 32, KB_SCREEN_WIDTH - 50, 700);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)dealloc {
|
||||||
|
// 移除通知监听
|
||||||
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - Actions
|
#pragma mark - Actions
|
||||||
|
|
||||||
- (void)onBack {
|
- (void)onBack {
|
||||||
@@ -129,6 +159,55 @@
|
|||||||
[self.navigationController popViewControllerAnimated:true];
|
[self.navigationController popViewControllerAnimated:true];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma mark - Video Player
|
||||||
|
|
||||||
|
// 初始化并开始在 cardView 中循环播放视频
|
||||||
|
- (void)kb_setupPermissionVideoPlayer {
|
||||||
|
// 避免重复初始化
|
||||||
|
if (self.kb_permPlayer) {
|
||||||
|
[self.kb_permPlayer play];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSURL *videoURL = [[NSBundle mainBundle] URLForResource:@"permiss_video" withExtension:@"mp4"];
|
||||||
|
if (!videoURL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AVPlayerItem *item = [AVPlayerItem playerItemWithURL:videoURL];
|
||||||
|
self.kb_permPlayer = [AVPlayer playerWithPlayerItem:item];
|
||||||
|
self.kb_permPlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone;
|
||||||
|
|
||||||
|
self.kb_permPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:self.kb_permPlayer];
|
||||||
|
// 使用等比模式,按我们计算好的 frame 显示;多余部分由容器裁剪
|
||||||
|
self.kb_permPlayerLayer.videoGravity = AVLayerVideoGravityResize;
|
||||||
|
self.kb_permPlayerLayer.cornerRadius = 20;
|
||||||
|
self.kb_permPlayerLayer.masksToBounds = true;
|
||||||
|
|
||||||
|
// 将视频图层插在按钮下面,保证按钮显示在视频之上
|
||||||
|
CALayer *buttonLayer = self.openButton.layer;
|
||||||
|
[self.view.layer insertSublayer:self.kb_permPlayerLayer below:buttonLayer];
|
||||||
|
|
||||||
|
// 播放结束后从头循环
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
|
selector:@selector(kb_playerItemDidReachEnd:)
|
||||||
|
name:AVPlayerItemDidPlayToEndTimeNotification
|
||||||
|
object:item];
|
||||||
|
|
||||||
|
[self.kb_permPlayer play];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)kb_playerItemDidReachEnd:(NSNotification *)note {
|
||||||
|
AVPlayerItem *item = (AVPlayerItem *)note.object;
|
||||||
|
if (!item) return;
|
||||||
|
|
||||||
|
__weak typeof(self) weakSelf = self;
|
||||||
|
[item seekToTime:kCMTimeZero completionHandler:^(BOOL finished) {
|
||||||
|
__strong typeof(weakSelf) strongSelf = weakSelf;
|
||||||
|
[strongSelf.kb_permPlayer play];
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - Lazy Subviews
|
#pragma mark - Lazy Subviews
|
||||||
|
|
||||||
- (UIButton *)backButton {
|
- (UIButton *)backButton {
|
||||||
@@ -164,17 +243,6 @@
|
|||||||
return _tipsLabel;
|
return _tipsLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (UIView *)cardView {
|
|
||||||
if (!_cardView) {
|
|
||||||
_cardView = [UIView new];
|
|
||||||
_cardView.backgroundColor = [UIColor whiteColor];
|
|
||||||
_cardView.layer.cornerRadius = 16;
|
|
||||||
_cardView.layer.shadowColor = [UIColor colorWithWhite:0 alpha:0.1].CGColor;
|
|
||||||
_cardView.layer.shadowOpacity = 1;
|
|
||||||
_cardView.layer.shadowRadius = 12;
|
|
||||||
}
|
|
||||||
return _cardView;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (UIButton *)openButton {
|
- (UIButton *)openButton {
|
||||||
if (!_openButton) {
|
if (!_openButton) {
|
||||||
|
|||||||
Reference in New Issue
Block a user