258 lines
8.4 KiB
Objective-C
258 lines
8.4 KiB
Objective-C
//
|
|
// GiGaAppGaurdVC.m
|
|
// GIGA
|
|
//
|
|
// Created by lianxiang on 2018/8/21.
|
|
// Copyright © 2018年 com.giga.ios. All rights reserved.
|
|
//
|
|
|
|
#import "GiGaAppGaurdVC.h"
|
|
#import "Masonry.h"
|
|
#import "GiGaUserDefault.h"
|
|
#import "GiGaPageControl.h"
|
|
#import "LXPageControl.h"
|
|
|
|
@interface GiGaAppGaurdVC ()<UIScrollViewDelegate>
|
|
@property(nonatomic,strong) LXPageControl *pagControl;
|
|
@property(nonatomic,strong)UIScrollView * scrollView;
|
|
|
|
@end
|
|
|
|
@implementation GiGaAppGaurdVC
|
|
- (LXPageControl *)pagControl
|
|
{
|
|
if (!_pagControl) {
|
|
_pagControl = [[LXPageControl alloc] initWithFrame:CGRectMake(0, KMainH - 63 - PhoneX_BottomMargin, KMainW, 8)];
|
|
_pagControl.numberOfPages = 3;
|
|
_pagControl.currentPage = 0;
|
|
|
|
}
|
|
return _pagControl;
|
|
}
|
|
- (UIScrollView *)scrollView
|
|
{
|
|
if (!_scrollView) {
|
|
_scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
|
|
_scrollView.backgroundColor = [UIColor redColor];
|
|
_scrollView.pagingEnabled=true;
|
|
_scrollView.delegate=self;
|
|
_scrollView.showsHorizontalScrollIndicator=false;
|
|
_scrollView.showsVerticalScrollIndicator=false;
|
|
}
|
|
return _scrollView;
|
|
}
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
// Do any additional setup after loading the view.
|
|
self.view.backgroundColor = [UIColor blackColor];
|
|
[GiGaUserDefault saveAppGaurdflag:YES];
|
|
[self creatSubs];
|
|
}
|
|
|
|
//MARK: - scrollView delegate
|
|
//结束滚动
|
|
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
|
|
|
|
[self updatePage];
|
|
}
|
|
|
|
-(void)updatePage{
|
|
|
|
self.pagControl.currentPage = self.scrollView.contentOffset.x / self.scrollView.bounds.size.width;
|
|
self.pagControl.hidden = self.scrollView.contentOffset.x / self.scrollView.bounds.size.width == 2 ? YES : NO;
|
|
GILog(@"%ld",self.pagControl.currentPage);
|
|
}
|
|
|
|
-(void)creatSubs{
|
|
|
|
[self.view addSubview:self.scrollView];
|
|
[self.view addSubview:self.pagControl];
|
|
self.scrollView.contentSize = CGSizeMake(self.scrollView.bounds.size.width*self.pagControl.numberOfPages, self.scrollView.bounds.size.height);
|
|
self.scrollView.bounces=NO;
|
|
|
|
for (int i=0; i<3; i++) {
|
|
UIView *pageView = [[UIView alloc] init];
|
|
pageView.backgroundColor = [UIColor blueColor];
|
|
pageView.frame = CGRectMake(i*self.scrollView.bounds.size.width, 0, self.scrollView.bounds.size.width, self.scrollView.bounds.size.height);
|
|
|
|
[self.scrollView addSubview:pageView];
|
|
|
|
if (i==0) {
|
|
[self creatFirstPage:pageView];
|
|
}else if (i==1){
|
|
[self creat2Page:pageView];
|
|
}else if (i==2){
|
|
[self creat3Page:pageView];
|
|
}
|
|
}
|
|
|
|
[self creatcommonView];
|
|
}
|
|
|
|
-(void)creatFirstPage:(UIView *)inView{
|
|
|
|
UIImageView *backimage = [[UIImageView alloc] init];
|
|
backimage.image = [UIImage imageNamed:@"appgaurd_bg"];
|
|
backimage.frame = CGRectMake(0, 0, KMainW, KMainH);
|
|
//backimage.contentMode = UIViewContentModeScaleToFill;
|
|
[inView addSubview:backimage];
|
|
|
|
[backimage mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(inView.mas_top);
|
|
make.bottom.mas_equalTo(inView.mas_bottom);
|
|
make.left.mas_equalTo(inView.mas_left);
|
|
make.right.mas_equalTo(inView.mas_right);
|
|
|
|
}];
|
|
UIImageView *girlimage = [[UIImageView alloc] init];
|
|
girlimage.image = [UIImage imageNamed:@"appgaurd_woman"];
|
|
[inView addSubview:girlimage];
|
|
girlimage.contentMode = UIViewContentModeScaleAspectFit;
|
|
[girlimage mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(inView.mas_top).offset(104 + PhoneX_TopMargin);
|
|
make.centerX.mas_equalTo(inView.mas_centerX);
|
|
|
|
|
|
}];
|
|
|
|
UIImageView *moonimage = [[UIImageView alloc] init];
|
|
moonimage.image = [UIImage imageNamed:@"appgaurd_moon"];
|
|
[inView addSubview:moonimage];
|
|
|
|
[moonimage mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(inView.mas_top).offset(13 + PhoneX_TopMargin);
|
|
make.right.mas_equalTo(inView.mas_right).offset(-24);
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
-(void)creat2Page:(UIView *)inView{
|
|
UIImageView *backimage = [[UIImageView alloc] init];
|
|
backimage.image = [UIImage imageNamed:@"page2_img"];
|
|
backimage.frame = CGRectMake(0, 0, KMainW, KMainH);
|
|
//backimage.contentMode = UIViewContentModeScaleToFill;
|
|
[inView addSubview:backimage];
|
|
|
|
UIImageView *girlimage = [[UIImageView alloc] init];
|
|
girlimage.image = [UIImage imageNamed:@"page2_women"];
|
|
[inView addSubview:girlimage];
|
|
girlimage.contentMode = UIViewContentModeScaleAspectFit;
|
|
[girlimage mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(inView.mas_top).offset(104 + PhoneX_TopMargin);
|
|
make.centerX.mas_equalTo(inView.mas_centerX);
|
|
|
|
|
|
}];
|
|
|
|
UIImageView *moonimage = [[UIImageView alloc] init];
|
|
moonimage.image = [UIImage imageNamed:@"appgaurd_moon"];
|
|
[inView addSubview:moonimage];
|
|
|
|
[moonimage mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(inView.mas_top).offset(13 + PhoneX_TopMargin);
|
|
make.right.mas_equalTo(inView.mas_right).offset(-24);
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
-(void)creat3Page:(UIView *)inView{
|
|
UIImageView *backimage = [[UIImageView alloc] init];
|
|
backimage.image = [UIImage imageNamed:@"page3_img"];
|
|
backimage.frame = CGRectMake(0, 0, KMainW, KMainH);
|
|
//backimage.contentMode = UIViewContentModeScaleToFill;
|
|
[inView addSubview:backimage];
|
|
|
|
|
|
UIImageView *girlimage = [[UIImageView alloc] init];
|
|
girlimage.image = [UIImage imageNamed:@"page3_woman"];
|
|
[inView addSubview:girlimage];
|
|
girlimage.contentMode = UIViewContentModeScaleAspectFit;
|
|
[girlimage mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(inView.mas_top).offset(104 + PhoneX_TopMargin);
|
|
make.centerX.mas_equalTo(inView.mas_centerX);
|
|
|
|
|
|
}];
|
|
|
|
UIImageView *logoimage = [[UIImageView alloc] init];
|
|
logoimage.image = [UIImage imageNamed:@"page_logo"];
|
|
[inView addSubview:logoimage];
|
|
|
|
[logoimage mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(inView.mas_top).offset(13 + PhoneX_TopMargin);
|
|
make.right.mas_equalTo(inView.mas_right).offset(-24);
|
|
|
|
}];
|
|
|
|
|
|
UIButton *dismisBtn= [UIButton buttonWithType:UIButtonTypeCustom];
|
|
[dismisBtn setTitle:@"立即体验" forState:UIControlStateNormal];
|
|
//dismisBtn.backgroundColor = [UIColor greenColor];
|
|
[dismisBtn addTarget:self action:@selector(dismisBtnAction) forControlEvents:UIControlEventTouchUpInside];
|
|
[inView addSubview:dismisBtn];
|
|
|
|
[dismisBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.width.mas_equalTo(160);
|
|
make.height.mas_equalTo(40);
|
|
make.centerX.mas_equalTo(inView.mas_centerX);
|
|
make.bottom.mas_equalTo(inView.mas_bottom).offset(-100);
|
|
make.top.mas_greaterThanOrEqualTo(girlimage.mas_bottom).offset(20);
|
|
}];
|
|
|
|
dismisBtn.layer.masksToBounds = YES;
|
|
dismisBtn.layer.cornerRadius = 20;
|
|
dismisBtn.layer.borderWidth = 1;
|
|
dismisBtn.layer.borderColor = [UIColor whiteColor].CGColor;
|
|
|
|
|
|
}
|
|
|
|
|
|
-(void)creatcommonView{
|
|
|
|
// UIImageView *moonimage = [[UIImageView alloc] init];
|
|
// moonimage.image = [UIImage imageNamed:@"appgaurd_moon"];
|
|
// [self.view addSubview:moonimage];
|
|
//
|
|
// [moonimage mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
// make.top.mas_equalTo(self.view.mas_top).offset(13 + PhoneX_TopMargin);
|
|
// make.right.mas_equalTo(self.view.mas_right).offset(-24);
|
|
//
|
|
// }];
|
|
|
|
UIView *botomlineView = [[UIView alloc] init];
|
|
botomlineView.backgroundColor = [UIColor whiteColor];
|
|
[self.view addSubview:botomlineView];
|
|
|
|
[botomlineView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.size.mas_equalTo(CGSizeMake(self.view.frame.size.width, 1));
|
|
make.bottom.mas_equalTo(self.view.mas_bottom).offset(-10 - PhoneX_BottomMargin);
|
|
make.centerX.mas_equalTo(self.view.mas_centerX);
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
-(void)dismisBtnAction{
|
|
|
|
[self dismissViewControllerAnimated:YES completion:^{
|
|
NC_POST_NAME_OBJECT(APP_GUARD_DISSMISS, nil);
|
|
}];
|
|
}
|
|
|
|
-(BOOL)prefersStatusBarHidden
|
|
{
|
|
return YES;
|
|
}
|
|
|
|
- (void)didReceiveMemoryWarning {
|
|
[super didReceiveMemoryWarning];
|
|
// Dispose of any resources that can be recreated.
|
|
}
|
|
|
|
@end
|