制作引导页[2]

简介:

制作引导页[2]

第二种制作引导页的方式,是直接在AppDelegate.m方法中进行的,在AppDelegate方法中,当视图控制器变得可视化的时候时候,我们就把引导页添加上.

效果还是一模一样的哦,只是比第一种方法更好而已:)

源码:

//
//  AppDelegate.m
//  Show
//
//  Copyright (c) 2014年 Y.X. All rights reserved.
//

#import "AppDelegate.h"
#import "RootViewController.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    
    // 接管控制器
    self.window.rootViewController = [RootViewController new];
    self.window.backgroundColor = [UIColor whiteColor];
    
    // 让视图可见
    [self.window makeKeyAndVisible];
    
    // 添加引导页
    [self scrollView];
    
    return YES;
}


- (void)scrollView
{
    CGRect rect    = self.window.bounds;
    CGFloat width  = rect.size.width;
    CGFloat height = rect.size.height;
    
    // 初始化scrollView
    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:rect];
    scrollView.pagingEnabled = YES;
    scrollView.tag           = 0x77;
    scrollView.contentSize   = CGSizeMake(width * 3, height);
    
    // 添加一些控件
    for (int i = 0; i < 3; i++)
    {
        UIView *tmp         = [[UIView alloc] initWithFrame:CGRectMake(i*width, 0, width, height)];
        tmp.backgroundColor = [UIColor colorWithRed:arc4random()%255/255.f
                                              green:arc4random()%255/255.f
                                               blue:arc4random()%255/255.f
                                              alpha:1];
        
        if (i == 2)
        {
            YXButton *button = [[YXButton alloc] initWithFrame:CGRectMake(0, 0, 140, 30)];
            button.titleLabel.font = [UIFont fontWithName:@"HelveticaNeue-Thin"
                                                     size:20.f];
            button.layer.cornerRadius = 3.f;
            [button addTarget:self
                       action:@selector(buttonEvent:)
             forControlEvents:UIControlEventTouchUpInside];
            [button setBackgroundColor:[UIColor blackColor]
            highlightedBackgroundColor:[UIColor whiteColor]];
            [button setNormalTitleColor:[UIColor whiteColor]
                  highlightedTitleColor:[UIColor blackColor]
                     disabledTitleColor:nil];
            [button setNormalTitle:@"YouXianMing"
                  highlightedTitle:@"YouXianMing"
                     disabledTitle:@"YouXianMing"];
            button.center = self.window.center;
            [tmp addSubview:button];
        }
        
        [scrollView addSubview:tmp];
    }
    
    // 添加到UIWindow当中
    [self.window addSubview:scrollView];
}


- (void)buttonEvent:(UIButton *)button
{
    UIScrollView *scrollView = (UIScrollView *)[self.window viewWithTag:0x77];
    scrollView.userInteractionEnabled = NO;
    
    // 动画
    [UIView animateWithDuration:2.0 animations:^{
        scrollView.alpha = 0.f;
    } completion:^(BOOL finished) {
        // 从UIWindow上移除这个scrollView
        [scrollView removeFromSuperview];
    }];
}


@end

目录
相关文章
|
3天前
宽屏好看的个人引导页源码
宽屏好看的个人引导页源码,源码由HTML+CSS+JS组成,记事本打开源码文件可以进行内容文字之类的修改,双击html文件可以本地运行效果
22 5
宽屏好看的个人引导页源码
|
4月前
HTML+CSS+JS实现十款好看的登录注册界面模板,赶紧收藏起来吧!(一)
HTML+CSS+JS实现十款好看的登录注册界面模板,赶紧收藏起来吧!
|
4月前
微信小游戏制作工具中关于背景图的设置
微信小游戏制作工具中关于背景图的设置
101 0
|
4月前
HTML+CSS+JS实现十款好看的登录注册界面模板,赶紧收藏起来吧!(二)
HTML+CSS+JS实现十款好看的登录注册界面模板,赶紧收藏起来吧!
|
8月前
免费制作属于自己的红包封面!附封面设计图下载
最近大家似乎对稀奇好看的红包封面已经见怪不怪了,很多人还每天到处找那些大企业发出来的红包封面。
124 0
|
9月前
|
计算机视觉
平面设计实验二 相册的制作与图层
平面设计实验二 相册的制作与图层
52 0
|
11月前
|
小程序 开发者
如何制作一个闪屏页面
闪屏(Splash)指的是当你打开一个应用时,首先映入眼帘的那个界面。通常闪屏页面都会比较简单,因为要一闪而过(这大概就是为什么叫做闪屏了),一般都会放置产品的 LOGO,在游戏中通常会放置游戏制作团队或者工作室的 LOGO。
142 0
|
小程序
【Axure教程】用中继器制作移动端图片上传效果
【Axure教程】用中继器制作移动端图片上传效果
【Axure教程】用中继器制作移动端图片上传效果
|
小程序
🍁商城类小程序实战(二):底部导航栏的制作
🍁商城类小程序实战(二):底部导航栏的制作
263 3
🍁商城类小程序实战(二):底部导航栏的制作
仿抖音注册界面制作
话说上次完成了仿抖音我的界面制作之后,今天抽空又把注册界面给做了,还是做了些小改动,将第三方登录去掉了 注册 还是老规矩直接奉上psd源码:仿抖音注册界面psd源码 个人博客https://myml666.
1240 0

热门文章

最新文章