哈哈突委,我是一個(gè)不會(huì)用markdown的人,之前的一個(gè)demo冬三,用markdown灰常簡(jiǎn)單的寫了這篇文章匀油, 這算文章么,哈哈勾笆,顯然有點(diǎn)不像啊敌蚜,有時(shí)間還得學(xué)學(xué)markdown啊, 這么簡(jiǎn)單的東西不會(huì)實(shí)在過(guò)不去窝爪,等我整理好github,以后這種東西我就上傳到github上吧弛车, 圖靈社區(qū)(貌似有markdown語(yǔ)法詳解)和github以及這里簡(jiǎn)書(shū)都支持markdown語(yǔ)法
########有點(diǎn)跑題,其實(shí)整篇都在跑題蒲每,大家喜歡這個(gè)引導(dǎo)頁(yè)的纷跛,看代碼吧。
在這里介紹兩個(gè)引導(dǎo)頁(yè)
//
// ViewController.m
// GuidePage
//
// Created by 李長(zhǎng)青 on 15/8/18.
// Copyright (c) 2015年 李長(zhǎng)青. All rights reserved.
//
#import "ViewController.h"
#define k_Base_Tag 10000
#define k_Rotate_Rate 1
#define K_SCREEN_WIDHT [UIScreen mainScreen].bounds.size.width //屏幕寬度
#define K_SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height //屏幕高
@interface ViewController ()<UIScrollViewDelegate>
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor colorWithRed:140.0/255 green:1 blue:1 alpha:1];
NSArray *imageArr = @[@"0.png",@"1.png",@"2.png",@"3.png"];
NSArray *textImageArr = @[@"5.png",@"6.png",@"7.png",@"8.png"];
UIScrollView *mainScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, K_SCREEN_WIDHT, K_SCREEN_HEIGHT)];
mainScrollView.pagingEnabled = YES;
mainScrollView.bounces = YES;
mainScrollView.contentSize = CGSizeMake(K_SCREEN_WIDHT*imageArr.count, K_SCREEN_HEIGHT);
mainScrollView.showsHorizontalScrollIndicator = NO;
mainScrollView.delegate = self;
[self.view addSubview:mainScrollView];
//添加云彩圖片
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 330, K_SCREEN_WIDHT, 170*K_SCREEN_WIDHT/1242.0)];
imageView.image = [UIImage imageNamed:@"yun.png"];
[self.view addSubview:imageView];
for (int i=0; i<imageArr.count; i++) {
UIView *rotateView = [[UIView alloc]initWithFrame:CGRectMake(K_SCREEN_WIDHT*i, 0, K_SCREEN_WIDHT, K_SCREEN_HEIGHT*2)];
[rotateView setTag:k_Base_Tag+i];
[mainScrollView addSubview:rotateView];
if (i!=0) {
rotateView.alpha = 0;
}
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, K_SCREEN_WIDHT, K_SCREEN_HEIGHT)];
imageView.image = [UIImage imageNamed:imageArr[i]];
[rotateView addSubview:imageView];
UIImageView *textImageView = [[UIImageView alloc]initWithFrame:CGRectMake(K_SCREEN_WIDHT*i, 50, K_SCREEN_WIDHT, K_SCREEN_WIDHT *260.0/1242.0)];
[textImageView setTag:k_Base_Tag*2+i];
textImageView.image = [UIImage imageNamed:textImageArr[i]];
[mainScrollView addSubview:textImageView];
//最后頁(yè)面添加按鈕
if (i == imageArr.count-1) {
UIControl *control = [[UIControl alloc]initWithFrame:CGRectMake(0, K_SCREEN_HEIGHT-80, K_SCREEN_WIDHT, 50)];
[control addTarget:self action:@selector(ClickToRemove) forControlEvents:UIControlEventTouchUpInside];
[rotateView addSubview:control];
}
}
UIView *firstView = [mainScrollView viewWithTag:k_Base_Tag];
[mainScrollView bringSubviewToFront:firstView];
}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
UIView * view1 = [scrollView viewWithTag:k_Base_Tag];
UIView * view2 = [scrollView viewWithTag:k_Base_Tag+1];
UIView * view3 = [scrollView viewWithTag:k_Base_Tag+2];
UIView * view4 = [scrollView viewWithTag:k_Base_Tag+3];
UIImageView * imageView1 = (UIImageView *)[scrollView viewWithTag:k_Base_Tag*2];
UIImageView * imageView2 = (UIImageView *)[scrollView viewWithTag:k_Base_Tag*2+1];
UIImageView * imageView3 = (UIImageView *)[scrollView viewWithTag:k_Base_Tag*2+2];
UIImageView * imageView4 = (UIImageView *)[scrollView viewWithTag:k_Base_Tag*2+3];
CGFloat xOffset = scrollView.contentOffset.x;
//根據(jù)偏移量旋轉(zhuǎn)
CGFloat rotateAngle = -1 * 1.0/K_SCREEN_WIDHT * xOffset * M_PI_2 * k_Rotate_Rate;
view1.layer.transform = CATransform3DMakeRotation(rotateAngle, 0, 0, 1);
view2.layer.transform = CATransform3DMakeRotation(M_PI_2*1+rotateAngle, 0, 0, 1);
view3.layer.transform = CATransform3DMakeRotation(M_PI_2*2+rotateAngle, 0, 0, 1);
view4.layer.transform = CATransform3DMakeRotation(M_PI_2*3+rotateAngle, 0, 0, 1);
//根據(jù)偏移量位移(保證中心點(diǎn)始終都在屏幕下方中間)
view1.center = CGPointMake(0.5 * K_SCREEN_WIDHT+xOffset, K_SCREEN_HEIGHT);
view2.center = CGPointMake(0.5 * K_SCREEN_WIDHT+xOffset, K_SCREEN_HEIGHT);
view3.center = CGPointMake(0.5 * K_SCREEN_WIDHT+xOffset, K_SCREEN_HEIGHT);
view4.center = CGPointMake(0.5 * K_SCREEN_WIDHT+xOffset, K_SCREEN_HEIGHT);
//當(dāng)前哪個(gè)視圖放在最上面
if (xOffset<K_SCREEN_WIDHT*0.5) {
[scrollView bringSubviewToFront:view1];
}else if (xOffset>=K_SCREEN_WIDHT*0.5 && xOffset < K_SCREEN_WIDHT*1.5){
[scrollView bringSubviewToFront:view2];
}else if (xOffset >=K_SCREEN_WIDHT*1.5 && xOffset < K_SCREEN_WIDHT*2.5){
[scrollView bringSubviewToFront:view3];
}else if (xOffset >=K_SCREEN_WIDHT*2.5)
{
[scrollView bringSubviewToFront:view4];
}
//調(diào)節(jié)其透明度
CGFloat xoffset_More = xOffset*1.5>K_SCREEN_WIDHT?K_SCREEN_WIDHT:xOffset*1.5;
if (xOffset < K_SCREEN_WIDHT) {
view1.alpha = (K_SCREEN_WIDHT - xoffset_More)/K_SCREEN_WIDHT;
imageView1.alpha = (K_SCREEN_WIDHT - xOffset)/K_SCREEN_WIDHT;;
}
if (xOffset <= K_SCREEN_WIDHT) {
view2.alpha = xoffset_More / K_SCREEN_WIDHT;
imageView2.alpha = xOffset / K_SCREEN_WIDHT;
}
if (xOffset >K_SCREEN_WIDHT && xOffset <= K_SCREEN_WIDHT*2) {
view2.alpha = (K_SCREEN_WIDHT*2 - xOffset)/K_SCREEN_WIDHT;
view3.alpha = (xOffset - K_SCREEN_WIDHT)/ K_SCREEN_WIDHT;
imageView2.alpha = (K_SCREEN_WIDHT*2 - xOffset)/K_SCREEN_WIDHT;
imageView3.alpha = (xOffset - K_SCREEN_WIDHT)/ K_SCREEN_WIDHT;
}
if (xOffset >K_SCREEN_WIDHT*2 ) {
view3.alpha = (K_SCREEN_WIDHT*3 - xOffset)/K_SCREEN_WIDHT;
view4.alpha = (xOffset - K_SCREEN_WIDHT*2)/ K_SCREEN_WIDHT;
imageView3.alpha = (K_SCREEN_WIDHT*3 - xOffset)/K_SCREEN_WIDHT;
imageView4.alpha = (xOffset - K_SCREEN_WIDHT*2)/ K_SCREEN_WIDHT;
}
//調(diào)節(jié)背景色
if (xOffset <K_SCREEN_WIDHT && xOffset>0) {
self.view.backgroundColor = [UIColor colorWithRed:(140-40.0/K_SCREEN_WIDHT*xOffset)/255.0 green:(255-25.0/K_SCREEN_WIDHT*xOffset)/255.0 blue:(255-100.0/K_SCREEN_WIDHT*xOffset)/255.0 alpha:1];
}else if (xOffset>=K_SCREEN_WIDHT &&xOffset<K_SCREEN_WIDHT*2){
self.view.backgroundColor = [UIColor colorWithRed:(100+30.0/K_SCREEN_WIDHT*(xOffset-K_SCREEN_WIDHT))/255.0 green:(230-40.0/K_SCREEN_WIDHT*(xOffset-K_SCREEN_WIDHT))/255.0 blue:(155-5.0/320*(xOffset-K_SCREEN_WIDHT))/255.0 alpha:1];
}else if (xOffset>=K_SCREEN_WIDHT*2 &&xOffset<K_SCREEN_WIDHT*3){
self.view.backgroundColor = [UIColor colorWithRed:(130-50.0/K_SCREEN_WIDHT*(xOffset-K_SCREEN_WIDHT*2))/255.0 green:(190-40.0/K_SCREEN_WIDHT*(xOffset-K_SCREEN_WIDHT*2))/255.0 blue:(150+50.0/K_SCREEN_WIDHT*(xOffset-K_SCREEN_WIDHT*2))/255.0 alpha:1];
}else if (xOffset>=K_SCREEN_WIDHT*3 &&xOffset<K_SCREEN_WIDHT*4){
self.view.backgroundColor = [UIColor colorWithRed:(80-10.0/K_SCREEN_WIDHT*(xOffset-K_SCREEN_WIDHT*3))/255.0 green:(150-25.0/K_SCREEN_WIDHT*(xOffset-K_SCREEN_WIDHT*3))/255.0 blue:(200-90.0/K_SCREEN_WIDHT*(xOffset-K_SCREEN_WIDHT*3))/255.0 alpha:1];
}
}
-(void)ClickToRemove
{
NSLog(@"點(diǎn)擊事件");
[self.view removeFromSuperview];
}
-(BOOL)shouldAutorotate
{
return YES;
}
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return (toInterfaceOrientation == UIInterfaceOrientationPortrait);
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
另一種引導(dǎo)頁(yè)邀杏,翻書(shū)效果的
#######這個(gè)是直接用UIPageViewController系統(tǒng)的贫奠,是不是幫幫噠的唬血, iOS6都支持哦
大家喜歡就收藏文章吧,真的棒棒噠
// SouFunSwipePageController.m
// soufun
//
// Created by jianjun zheng on 12-1-9.
// updateby 李長(zhǎng)青 2015-04-22
// 版本7.6.0
#import "SouFunSwipePageUpdateViewController.h"
#import "SouFunAppDelegate.h"
#import "SouFunAppLauchService.h"
@interface SouFunSwipePageUpdateViewController()<UIPageViewControllerDataSource,UIPageViewControllerDelegate>
//page控制器
@property (nonatomic,strong)UIPageViewController * pageVC;
//控制器數(shù)組
@property (nonatomic,strong)NSMutableArray *viewControllers;
@end
@implementation SouFunSwipePageUpdateViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
NSMutableArray *vcs = [[NSMutableArray alloc] init];
self.viewControllers = vcs;
for (NSUInteger i = 0; i < 4; i++) {
UIViewController * controller = [[UIViewController alloc] init];
UIImageView * imageView = [[UIImageView alloc] initWithFrame:controller.view.bounds];
if (iPhone5 || iPhone6 || iPhone6Plus) {
imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"SouFunYinDaoYe0%ziiphone5.png",i+1]];
}else{
imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"SouFunYinDaoYe0%zi.png",i+1]];
}
imageView.tag = 1000+i;
[controller.view addSubview:imageView];
if (i == 3) {
UIControl *btn = [[UIControl alloc]initWithFrame:CGRectMake(145/2, controller.view.bounds.size.height-120-40, (KSCREEN_WIDTH-145), 120) ];
[btn addTarget:self action:@selector(disAppearView) forControlEvents:UIControlEventTouchUpInside];
[controller.view addSubview:btn];
}
[self.viewControllers addObject:controller];
}
NSDictionary * options = [NSDictionary dictionaryWithObject:[NSNumber numberWithInteger:UIPageViewControllerSpineLocationMin] forKey:UIPageViewControllerOptionSpineLocationKey];
self.pageVC = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:options];
self.pageVC.dataSource = self;
self.pageVC.delegate = self;
self.pageVC.view.frame = self.view.bounds;
UIViewController * controller = self.viewControllers[0];
NSArray *viewControllers =[NSArray arrayWithObject:controller];
[self.pageVC setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
[self.view addSubview:self.pageVC.view];
}
#pragma - mark datasource
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController{
NSInteger number = [viewController.view.subviews objectAtIndex:0].tag-1000;
if (number == NSNotFound) {
return nil;
}
number++;
if (number >= [self.viewControllers count]) {
return nil;
}
return [self.viewControllers objectAtIndex:number];
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController{
NSInteger number = [viewController.view.subviews objectAtIndex:0].tag-1000;
if ((number == 0) || (number == NSNotFound)) {
return nil;
}
number--;
return [self.viewControllers objectAtIndex:number];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (void)disAppearView
{
[SouFunAppLauchService sharedSouFunAppLauchService].isFirstLaunch=NO;
[self.view removeFromSuperview];
}
@end