iOS-火爆的旋轉(zhuǎn)式引導(dǎo)頁(yè)你見(jiàn)過(guò)么(源碼)

哈哈突委,我是一個(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è)


問(wèn)題15.gif

//
//  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都支持哦
大家喜歡就收藏文章吧,真的棒棒噠

問(wèn)題16.gif

//  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

快來(lái)關(guān)注一編唤崭, 關(guān)注拷恨,沒(méi)錯(cuò)就是關(guān)注, 這樣小編會(huì)更加努力的給你找資源谢肾,找資源腕侄,找資源,分享芦疏,分享冕杠,分享,你的關(guān)注是我最大的支持C蟹帧0杌恪!

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末弊决,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子魁淳,更是在濱河造成了極大的恐慌飘诗,老刑警劉巖,帶你破解...
    沈念sama閱讀 212,884評(píng)論 6 492
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件界逛,死亡現(xiàn)場(chǎng)離奇詭異昆稿,居然都是意外死亡,警方通過(guò)查閱死者的電腦和手機(jī)息拜,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,755評(píng)論 3 385
  • 文/潘曉璐 我一進(jìn)店門溉潭,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人少欺,你說(shuō)我怎么就攤上這事喳瓣。” “怎么了赞别?”我有些...
    開(kāi)封第一講書(shū)人閱讀 158,369評(píng)論 0 348
  • 文/不壞的土叔 我叫張陵畏陕,是天一觀的道長(zhǎng)。 經(jīng)常有香客問(wèn)我仿滔,道長(zhǎng)惠毁,這世上最難降的妖魔是什么? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 56,799評(píng)論 1 285
  • 正文 為了忘掉前任崎页,我火速辦了婚禮鞠绰,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘飒焦。我一直安慰自己蜈膨,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,910評(píng)論 6 386
  • 文/花漫 我一把揭開(kāi)白布。 她就那樣靜靜地躺著丈挟,像睡著了一般刁卜。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上曙咽,一...
    開(kāi)封第一講書(shū)人閱讀 50,096評(píng)論 1 291
  • 那天蛔趴,我揣著相機(jī)與錄音,去河邊找鬼例朱。 笑死孝情,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的洒嗤。 我是一名探鬼主播箫荡,決...
    沈念sama閱讀 39,159評(píng)論 3 411
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼渔隶!你這毒婦竟也來(lái)了羔挡?” 一聲冷哼從身側(cè)響起,我...
    開(kāi)封第一講書(shū)人閱讀 37,917評(píng)論 0 268
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤间唉,失蹤者是張志新(化名)和其女友劉穎绞灼,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體呈野,經(jīng)...
    沈念sama閱讀 44,360評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡低矮,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,673評(píng)論 2 327
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了被冒。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片军掂。...
    茶點(diǎn)故事閱讀 38,814評(píng)論 1 341
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖昨悼,靈堂內(nèi)的尸體忽然破棺而出蝗锥,到底是詐尸還是另有隱情,我是刑警寧澤幔戏,帶...
    沈念sama閱讀 34,509評(píng)論 4 334
  • 正文 年R本政府宣布玛追,位于F島的核電站,受9級(jí)特大地震影響闲延,放射性物質(zhì)發(fā)生泄漏痊剖。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 40,156評(píng)論 3 317
  • 文/蒙蒙 一垒玲、第九天 我趴在偏房一處隱蔽的房頂上張望陆馁。 院中可真熱鬧,春花似錦合愈、人聲如沸叮贩。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 30,882評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)益老。三九已至彪蓬,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間捺萌,已是汗流浹背档冬。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 32,123評(píng)論 1 267
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留桃纯,地道東北人酷誓。 一個(gè)月前我還...
    沈念sama閱讀 46,641評(píng)論 2 362
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像态坦,于是被迫代替她去往敵國(guó)和親盐数。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,728評(píng)論 2 351

推薦閱讀更多精彩內(nèi)容