• 设置引导页(第一次登陆进入引导页)


    #import <UIKit/UIKit.h>
    
    @interface AppDelegate : UIResponder <UIApplicationDelegate>
    
    @property (strong, nonatomic) UIWindow *window;
    
    
    @end
    #import "AppDelegate.h"
    #import "GuideViewController.h"
    #import "RootViewController.h"
    
    @interface AppDelegate ()
    
    @end
    
    @implementation AppDelegate
    
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        // Override point for customization after application launch.
        self.window.backgroundColor = [UIColor whiteColor];
        // 判断是否是第一次登陆
        if (![[NSUserDefaults standardUserDefaults] objectForKey:@"FirstLaunch"]) {
            [[NSUserDefaults standardUserDefaults] setObject:@(true) forKey:@"FirstLaunch"];
            self.window.rootViewController = [[GuideViewController alloc] init];
        }else{
            self.window.rootViewController = [[RootViewController alloc] init];
        }
        
        [self.window makeKeyAndVisible];
        return YES;
    }
    @end
    #import <UIKit/UIKit.h>
    
    @interface GuideViewController : UIViewController
    
    @end
    #import "GuideViewController.h"
    #import "RootViewController.h"
    
    @interface GuideViewController ()
    
    @end
    
    @implementation GuideViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        // 初始化scrollView
        UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        // 隐藏水平滚动条
        scrollView.showsHorizontalScrollIndicator = NO;
        // 翻页效果
        scrollView.pagingEnabled = YES;
        // 设置scrollView的内容窗口大小
        scrollView.contentSize = CGSizeMake([UIScreen mainScreen].bounds.size.width * 3, [UIScreen mainScreen].bounds.size.height);
        [self.view addSubview:scrollView];
        // 设置滚动图片
        NSArray *array = [[NSArray alloc] initWithObjects:@"1-1.jpg",@"1-2.jpg",@"1-3.jpg", nil];
        for (int i = 0; i < array.count; i++) {
            UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:array[i]]];
            imageView.frame = CGRectMake([UIScreen mainScreen].bounds.size.width * i, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
            [scrollView addSubview:imageView];
            imageView.tag = 1000 + i;
        }
        // 获取最后一个imageView,然后在其上面加button
        UIImageView *imgView = [self.view viewWithTag:1002];
        // 父视图要可操作,否则其上面的子视图(button)不可操作
        imgView.userInteractionEnabled = YES;
        // 设置button
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        btn.frame = CGRectMake(([UIScreen mainScreen].bounds.size.width - 150)/2.0, [UIScreen mainScreen].bounds.size.height - 120, 150, 80);
        [btn setBackgroundColor:[UIColor clearColor]];
        [btn setTitle:@"马上体验" forState:0];
        [btn setTitleColor:[UIColor redColor] forState:0];
        [btn addTarget:self action:@selector(comeToRootController:) forControlEvents:UIControlEventTouchUpInside];
        [imgView addSubview:btn];
    }
    
    
    
    - (void)comeToRootController:(UIButton *)sender{
        
        RootViewController *root = [[RootViewController alloc] init];
        UIApplication *app = [UIApplication sharedApplication];
        app.keyWindow.rootViewController = root;
    }
    
    @end
    #import <UIKit/UIKit.h>
    
    @interface RootViewController : UIViewController
    
    @end
    #import "RootViewController.h"
    
    @interface RootViewController ()
    
    @end
    
    @implementation RootViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        self.view.backgroundColor = [UIColor orangeColor];
    }
    
    @end
  • 相关阅读:
    ES2017 新特性:Async Functions (异步函数)
    为什么 window.location.search 为空?
    vue-cli 构建Vue项目后的打包和发布
    Vue.js父子组件如何传值 通俗易懂
    vue 面试题(文章末尾还有其他链接)
    vue组件命名和传值 and 父子组件传值
    line-gradient 之渐变角度
    vue-router路由模式
    vue-router 去掉#
    记录vue项目上线遇到的一些问题
  • 原文地址:https://www.cnblogs.com/lantu1989/p/4941043.html
Copyright © 2020-2023  润新知