IOS boot page

Source: Internet
Author: User

IOS boot page

/

// ADo_ViewController.m

// ADo_GuideView

//

// Created by dwx on 15/5/1.

// Copyright (c) 2015 Nododo. All rights reserved.

//

 

# Import "ADo_ViewController.h"

// # Import "ADo_SecViewController.h"

# Import "UIView + Extension. h"

# Import "homeViewController. h"

# Define screenW self. view. frame. size. width

# Define screenH self. view. frame. size. height

# Define pageCount 5

# Define picH 2330/2

# Define padding 200

# Define topPicH 70

# Define topPicW 112

# Define btnH 100

# Define btnW 140

@ Interface ADo_ViewController ()

/**

* Scroll image at the bottom

*/

@ Property (nonatomic, strong) UIScrollView * guideView;

/**

* Spherical image

*/

@ Property (nonatomic, strong) UIImageView * picView;

/**

* Card Rolling

*/

@ Property (nonatomic, strong) UIImageView * lateral view;

/**

* Instructions

*/

@ Property (nonatomic, strong) UIPageControl * pageControl;

/**

* Top image scrolling

*/

@ Property (nonatomic, strong) UIScrollView * topView;

@ End

 

@ Implementation ADo_ViewController

 

-(Void) viewDidLoad {

[Super viewDidLoad];

/**

Background Image

*/

UIImageView * backView = [[UIImageView alloc] initWithFrame: self. view. frame];

BackView. image = [UIImage imageNamed: @ "page_bg_35"];

[Self. view addSubview: backView];

 

/**

Rolling assistance

*/

UIScrollView * ado_guideView = [[UIScrollView alloc] initWithFrame: self. view. frame];

Ado_guideView.contentSize = CGSizeMake (screenW * pageCount, screenH );

Ado_guideView.bounces = NO;

Ado_guideView.pagingEnabled = YES;

Ado_guideView.delegate = self;

Ado_guideView.showsHorizontalScrollIndicator = NO;

 

/**

Scroll ball

 

*/

UIImageView * picView = [[UIImageView alloc] init];

PicView. width = picH;

PicView. height = picH;

PicView. centerX = screenW/2;

PicView. centerY = screenH + padding;

# Setting the anchor in warning is a pitfall

PicView. layer. anchorPoint = CGPointMake (0.5, 0.5 );

PicView. image = [UIImage imageNamed: @ "guider_qiu_35"];

 

/**

Scroll card

*/

UIImageView * lateral view = [[UIImageView alloc] init];

Lateral view. width = picH;

Lateral view. height = picH;

Lateral view. centerX = screenW/2;

Lateral view. centerY = screenH + padding;

Lateral view. layer. anchorPoint = CGPointMake (0.5, 0.5 );

Lateral view. image = [UIImage imageNamed: @ "guider_assist_35"];

 

/**

Indicator

*/

UIPageControl * pageControl = [[UIPageControl alloc] initWithFrame: CGRectMake (screenW/2-50, screenH-20,100, 20)];

PageControl. numberOfPages = 5;

PageControl. currentPage = 0;

PageControl. pageIndicatorTintColor = [UIColor colorWithRed: 0 green: 0 blue: 0 alpha: 0.1];

PageControl. currentPageIndicatorTintColor = [UIColor whiteColor];

[BackView addSubview: pageControl];

 

/**

Scroll image on top

*/

UIScrollView * topView = [[UIScrollView alloc] initWithFrame: CGRectMake (0, 20, screenW, topPicH)];

TopView. contentSize = CGSizeMake (screenW * pageCount, topPicH );

TopView. bounces = NO;

TopView. pagingEnabled = YES;

For (int I = 0; I <pageCount; I ++ ){

UIImageView * topPic = [[UIImageView alloc] init];

TopPic. width = topPicW;

TopPic. height = topPicH;

TopPic. centerX = I * screenW + screenW/2;

TopPic. y = 0;

NSString * picName = [NSString stringWithFormat: @ "page_top _ % d", I];

TopPic. image = [UIImage imageNamed: picName];

[TopView addSubview: topPic];

}

[BackView addSubview: topView];

Self. topView = topView;

 

Self. pageControl = pageControl;

[Self. view addSubview: lateral view];

[Self. view addSubview: picView];

[Self. view addSubview: ado_guideView];

Self. guideView = ado_guideView;

Self. picView = picView;

Self. Lateral view = lateral view;

 

}

# Pragma mark-privateMethod

-(Void) addGuideController {

 

If (! [[NSUserDefaults standardUserDefaults] boolForKey: @ "isFirstEnterApp"]) {

UIStoryboard * storyboard = [UIStoryboard storyboardWithName: @ "Main" bundle: nil];

ADo_ViewController * guide = [storyboard instantiateViewControllerWithIdentifier: @ "ado"];

 

[Self addChildViewController: guide];

Guide. view. frame = self. view. bounds;

[Self. view addSubview: guide. view];

[[NSUserDefaults standardUserDefaults] setBool: YES forKey: @ "isFirstEnterApp"];

}

}

/**

* Modal to next page

*

*/

-(Void) go2MainVC :( UIButton *) btn

{

// UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @ "you clicked" message: nil delegate: self cancelButtonTitle: @ "OK" otherButtonTitles: nil, nil];

// [Alert show];

 

[Self. navigationController dismissViewControllerAnimated: YES completion: nil];

HomeViewController * view = [self. storyboard instantiateViewControllerWithIdentifier: @ "zhujiemian"];

[Self. navigationController pushViewController: view animated: YES];

}

 

/**

* ScrollView proxy method

*/

-(Void) scrollViewDidScroll :( UIScrollView *) scrollView

{

Float offSetX = scrollView. contentOffset. x;

Self. picView. layer. transform = CATransform3DMakeRotation (-offSetX * (M_PI)/screenW/3, 0, 0, 1 );

Self. Lateral view. layer. transform = CATransform3DMakeRotation (-offSetX * (M_PI)/screenW/3, 0, 0, 1 );

Self. pageControl. currentPage = scrollView. contentOffset. x/screenW;

 

 

If (self. pageControl. currentPage = 4 ){

UIButton * nextBtn = [[UIButton alloc] initWithFrame: CGRectMake (screenW/2 + offSetX-btnW/2, screenH-155, btnW, btnH)];

[NextBtn addTarget: self action: @ selector (go2MainVC :) forControlEvents: UIControlEventTouchUpInside];

NextBtn. backgroundColor = [UIColor clearColor];

[ScrollView addSubview: nextBtn];

}

 

 

Self. topView. contentOffset = CGPointMake (offSetX, 0 );

}

 

@ End

 

 

//

// ADo_ViewController.m

// ADo_GuideView

//

// Created by dwx on 15/5/1.

// Copyright (c) 2015 Nododo. All rights reserved.

//

 

# Import "ADo_ViewController.h"

// # Import "ADo_SecViewController.h"

# Import "UIView + Extension. h"

# Import "homeViewController. h"

# Define screenW self. view. frame. size. width

# Define screenH self. view. frame. size. height

# Define pageCount 5

# Define picH 2330/2

# Define padding 200

# Define topPicH 70

# Define topPicW 112

# Define btnH 100

# Define btnW 140

@ Interface ADo_ViewController ()

/**

* Scroll image at the bottom

*/

@ Property (nonatomic, strong) UIScrollView * guideView;

/**

* Spherical image

*/

@ Property (nonatomic, strong) UIImageView * picView;

/**

* Card Rolling

*/

@ Property (nonatomic, strong) UIImageView * lateral view;

/**

* Instructions

*/

@ Property (nonatomic, strong) UIPageControl * pageControl;

/**

* Top image scrolling

*/

@ Property (nonatomic, strong) UIScrollView * topView;

@ End

 

@ Implementation ADo_ViewController

 

-(Void) viewDidLoad {

[Super viewDidLoad];

/**

Background Image

*/

UIImageView * backView = [[UIImageView alloc] initWithFrame: self. view. frame];

BackView. image = [UIImage imageNamed: @ "page_bg_35"];

[Self. view addSubview: backView];

 

/**

Rolling assistance

*/

UIScrollView * ado_guideView = [[UIScrollView alloc] initWithFrame: self. view. frame];

Ado_guideView.contentSize = CGSizeMake (screenW * pageCount, screenH );

Ado_guideView.bounces = NO;

Ado_guideView.pagingEnabled = YES;

Ado_guideView.delegate = self;

Ado_guideView.showsHorizontalScrollIndicator = NO;

 

/**

Scroll ball

 

*/

UIImageView * picView = [[UIImageView alloc] init];

PicView. width = picH;

PicView. height = picH;

PicView. centerX = screenW/2;

PicView. centerY = screenH + padding;

# Setting the anchor in warning is a pitfall

PicView. layer. anchorPoint = CGPointMake (0.5, 0.5 );

PicView. image = [UIImage imageNamed: @ "guider_qiu_35"];

 

/**

Scroll card

*/

UIImageView * lateral view = [[UIImageView alloc] init];

Lateral view. width = picH;

Lateral view. height = picH;

Lateral view. centerX = screenW/2;

Lateral view. centerY = screenH + padding;

Lateral view. layer. anchorPoint = CGPointMake (0.5, 0.5 );

Lateral view. image = [UIImage imageNamed: @ "guider_assist_35"];

 

/**

Indicator

*/

UIPageControl * pageControl = [[UIPageControl alloc] initWithFrame: CGRectMake (screenW/2-50, screenH-20,100, 20)];

PageControl. numberOfPages = 5;

PageControl. currentPage = 0;

PageControl. pageIndicatorTintColor = [UIColor colorWithRed: 0 green: 0 blue: 0 alpha: 0.1];

PageControl. currentPageIndicatorTintColor = [UIColor whiteColor];

[BackView addSubview: pageControl];

 

/**

Scroll image on top

*/

UIScrollView * topView = [[UIScrollView alloc] initWithFrame: CGRectMake (0, 20, screenW, topPicH)];

TopView. contentSize = CGSizeMake (screenW * pageCount, topPicH );

TopView. bounces = NO;

TopView. pagingEnabled = YES;

For (int I = 0; I <pageCount; I ++ ){

UIImageView * topPic = [[UIImageView alloc] init];

TopPic. width = topPicW;

TopPic. height = topPicH;

TopPic. centerX = I * screenW + screenW/2;

TopPic. y = 0;

NSString * picName = [NSString stringWithFormat: @ "page_top _ % d", I];

TopPic. image = [UIImage imageNamed: picName];

[TopView addSubview: topPic];

}

[BackView addSubview: topView];

Self. topView = topView;

 

Self. pageControl = pageControl;

[Self. view addSubview: lateral view];

[Self. view addSubview: picView];

[Self. view addSubview: ado_guideView];

Self. guideView = ado_guideView;

Self. picView = picView;

Self. Lateral view = lateral view;

 

}

# Pragma mark-privateMethod

-(Void) addGuideController {

 

If (! [[NSUserDefaults standardUserDefaults] boolForKey: @ "isFirstEnterApp"]) {

UIStoryboard * storyboard = [UIStoryboard storyboardWithName: @ "Main" bundle: nil];

ADo_ViewController * guide = [storyboard instantiateViewControllerWithIdentifier: @ "ado"];

 

[Self addChildViewController: guide];

Guide. view. frame = self. view. bounds;

[Self. view addSubview: guide. view];

[[NSUserDefaults standardUserDefaults] setBool: YES forKey: @ "isFirstEnterApp"];

}

}

/**

* Modal to next page

*

*/

-(Void) go2MainVC :( UIButton *) btn

{

// UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @ "you clicked" message: nil delegate: self cancelButtonTitle: @ "OK" otherButtonTitles: nil, nil];

// [Alert show];

 

[Self. navigationController dismissViewControllerAnimated: YES completion: nil];

HomeViewController * view = [self. storyboard instantiateViewControllerWithIdentifier: @ "zhujiemian"];

[Self. navigationController pushViewController: view animated: YES];

}

 

/**

* ScrollView proxy method

*/

-(Void) scrollViewDidScroll :( UIScrollView *) scrollView

{

Float offSetX = scrollView. contentOffset. x;

Self. picView. layer. transform = CATransform3DMakeRotation (-offSetX * (M_PI)/screenW/3, 0, 0, 1 );

Self. Lateral view. layer. transform = CATransform3DMakeRotation (-offSetX * (M_PI)/screenW/3, 0, 0, 1 );

Self. pageControl. currentPage = scrollView. contentOffset. x/screenW;

 

 

If (self. pageControl. currentPage = 4 ){

UIButton * nextBtn = [[UIButton alloc] initWithFrame: CGRectMake (screenW/2 + offSetX-btnW/2, screenH-155, btnW, btnH)];

[NextBtn addTarget: self action: @ selector (go2MainVC :) forControlEvents: UIControlEventTouchUpInside];

NextBtn. backgroundColor = [UIColor clearColor];

[ScrollView addSubview: nextBtn];

}

 

 

Self. topView. contentOffset = CGPointMake (offSetX, 0 );

}

 

@ End

 

# Import

 

@ Interface UIView (Extension)

@ Property (nonatomic, assign) CGFloat x;

@ Property (nonatomic, assign) CGFloat y;

@ Property (nonatomic, assign) CGFloat maxX;

@ Property (nonatomic, assign) CGFloat maxY;

@ Property (nonatomic, assign) CGFloat centerX;

@ Property (nonatomic, assign) CGFloat centerY;

@ Property (nonatomic, assign) CGFloat width;

@ Property (nonatomic, assign) CGFloat height;

@ Property (nonatomic, assign) CGSize size;

@ End


 

# Import "UIView + Extension. h"

 

@ Implementation UIView (Extension)

 

-(Void) setX :( CGFloat) x

{

CGRect frame = self. frame;

Frame. origin. x = x;

Self. frame = frame;

}

 

-(CGFloat) x

{

Return self. frame. origin. x;

}

 

-(Void) setMaxX :( CGFloat) maxX

{

Self. x = maxX-self. width;

}

 

-(CGFloat) maxX

{

Return CGRectGetMaxX (self. frame );

}

 

-(Void) setMaxY :( CGFloat) maxY

{

Self. y = maxY-self. height;

}

 

-(CGFloat) maxY

{

Return CGRectGetMaxY (self. frame );

}

 

-(Void) setY :( CGFloat) y

{

CGRect frame = self. frame;

Frame. origin. y = y;

Self. frame = frame;

}

 

-(CGFloat) y

{

Return self. frame. origin. y;

}

 

-(Void) setCenterX :( CGFloat) centerX

{

CGPoint center = self. center;

Center. x = centerX;

Self. center = center;

}

 

-(CGFloat) centerX

{

Return self. center. x;

}

 

-(Void) setCenterY :( CGFloat) centerY

{

CGPoint center = self. center;

Center. y = centerY;

Self. center = center;

}

 

-(CGFloat) centerY

{

Return self. center. y;

}

 

-(Void) setWidth :( CGFloat) width

{

CGRect frame = self. frame;

Frame. size. width = width;

Self. frame = frame;

}

 

-(CGFloat) width

{

Return self. frame. size. width;

}

 

-(Void) setHeight :( CGFloat) height

{

CGRect frame = self. frame;

Frame. size. height = height;

Self. frame = frame;

}

 

-(CGFloat) height

{

Return self. frame. size. height;

}

 

-(Void) setSize :( CGSize) size

{

CGRect frame = self. frame;

Frame. size = size;

Self. frame = frame;

}

 

-(CGSize) size

{

Return self. frame. size;

}

 

@ End




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.