美文网首页
启动界面之新特性

启动界面之新特性

作者: Mr丶炎 | 来源:发表于2016-07-12 18:52 被阅读20次

1、创建window分类
2、沙盒进行版本判断
3、新特性控制器切换

创建window分类,判断版本

#import "UIWindow+ALExtension.h"
#import "ALTabBarViewController.h"
#import "ALNewViewController.h"

@implementation UIWindow (ALExtension)

- (void)switchRootViewController {
    
    // 之前已经登录成功过
    NSString *key = @"CFBundleVersion";
    // 上一次的使用版本(存储在沙盒中的版本号)
    NSString *lastVersion = [[NSUserDefaults standardUserDefaults] objectForKey:key];
    
    // 当前软件的版本号(info.plist中获得)
    NSString *currentVersion = [NSBundle mainBundle].infoDictionary[key];
    
    if ([currentVersion isEqualToString:lastVersion]) {
        // 版本相同,这次打开和上次打开是同一个版本
        self.rootViewController =  [[ALTabBarViewController alloc] init];
        
    } else {
        // 这次打开的和上一次不一样
        self.rootViewController = [[ALNewViewController alloc] init];
        
        // 将当前的版本号存进沙盒
        [[NSUserDefaults standardUserDefaults]setObject:currentVersion forKey:key];
        // 马上同步到沙盒
        [[NSUserDefaults standardUserDefaults] synchronize];
    }
    
}

新特性控制器

#import "ALNewViewController.h"
#import "ALTabBarViewController.h"

#define KWidth self.view.frame.size.width
#define KHeight self.view.frame.size.height
#define ALNewCount 4

@interface ALNewViewController () <UIScrollViewDelegate>

@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;

@property (weak, nonatomic) IBOutlet UIPageControl *pageControl;


@end

@implementation ALNewViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 创建图片
    for (int i = 0; i < ALNewCount; i++) {
        
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(i * KWidth, 0, KWidth, KHeight)];
        imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"workth0%d", i + 1]];
        
        [self.scrollView addSubview:imageView];
        
        if (i == ALNewCount - 1) {
            [self setupLastImageView:imageView];
        }
        
    }
    
    self.pageControl.numberOfPages = ALNewCount;
    
    self.scrollView.contentSize = CGSizeMake(ALNewCount * KWidth, 0);
    
    
}

#pragma mark - 进入主界面
- (void)setupLastImageView:(UIImageView *)imageView {
    
    // 开启用户交互
    imageView.userInteractionEnabled = YES;
    
    UIButton *enter = [[UIButton alloc] init];
    enter.frame = CGRectMake(0, KHeight - 100, KWidth, 30);
    [enter setTitle:@"进入阿里星球之旅" forState:UIControlStateNormal];
    [enter setBackgroundImage:[UIImage imageNamed:@"nav_bg"] forState:UIControlStateNormal];
    
    [imageView addSubview:enter];
    [enter addTarget:self action:@selector(startClick) forControlEvents:UIControlEventTouchUpInside];
    
    
}

// 切换
- (void)startClick {
    UIWindow *window = [UIApplication sharedApplication].keyWindow;
    window.rootViewController = [[ALTabBarViewController alloc] init];
}

#pragma UIScrollViewDelegate
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {

    self.pageControl.currentPage =  (int)(scrollView.contentOffset.x / scrollView.frame.size.width + 0.5);
    
    
}

相关文章

  • 启动界面之新特性

    1、创建window分类2、沙盒进行版本判断3、新特性控制器切换 创建window分类,判断版本 新特性控制器

  • 9.0 UIScrollView+UIPageControl实现

    需求: 启动程序后,有个介绍app新特性的界面 思路: 新特性界面,其实就多个图片组合在一起,展示出来而已! 使用...

  • 新特性界面

    要实现开机启动后能够展示新的版本的应用的一些新特性,需要在-(BOOL)application:(UIApplic...

  • iOS 新特性界面

    .m .h AppDelegate.m

  • 学习HM微博项目第3天

    步骤:自定义tabBar -> 版本新特性01-搭载界面 -> 版本新特性02-按钮的使用细节 ->...

  •       新特性引导页

    在我们做程序维护和版本迭代工作中,我们经常会做新特性界面(闪屏页过后的引导界面),做新特性界面的逻辑思维就是在Ap...

  • system

    Centos 7启动流程 systemd新特性 核心概念:unit Unit的类型: systemd特性 管理系统...

  • UI项目

    图片 新特性界面搭建方法(4种) ScrollView TableView 指针 CollectionView(选...

  • Swift UIScrollView完成新特性界面

    引言 UIScrollView在实际的项目开发中使用的比较多,可以很好展示图片 说下思路,根据APP的版本来决定是...

  • 4 首页布局

    欢迎界面在新特性模块下创建welcomeViewController加载背景 头像 切头像cornerradius...

网友评论

      本文标题:启动界面之新特性

      本文链接:https://www.haomeiwen.com/subject/lzksjttx.html