zoukankan      html  css  js  c++  java
  • 自定义App首次启动引导页

    代码如下
    #import"ZBGuidePageView.h"
     
    @interfaceZBGuidePageView()<UIScrollViewDelegate>
     
    @property(nonatomic,strong)UIScrollView*scrollView;
    @property(nonatomic,strong)UIPageControl*pageControl;
     
    @end
     
    @implementationZBGuidePageView
     
    NSString*key =@"CFBundleShortVersionString";
     
    - (void)show {
       
       NSString*key =@"CFBundleShortVersionString";
       
       //获得当前软件的版本号
       NSString*currentVersion = [NSBundlemainBundle].infoDictionary[key];
       
       //获得沙盒中存储的版本号
       NSString*sanboxVersion = [[NSUserDefaultsstandardUserDefaults]stringForKey:key];
       
       if(![currentVersionisEqualToString:sanboxVersion]) {
           
           //自定义引导界面
            [selfpushGuideView];
           
           //存储版本号
            [[NSUserDefaultsstandardUserDefaults]setObject:currentVersionforKey:key];
           
           //立即存储
            [[NSUserDefaultsstandardUserDefaults]synchronize];
           
        }
       
    }
     
    //加载视图
    - (void)pushGuideView {
       UIWindow*window = [UIApplicationsharedApplication].keyWindow;
       self.frame= window.bounds;
        [windowaddSubview:self];
       //创建引导的滑动视图
       _scrollView= [[UIScrollViewalloc]initWithFrame:CGRectMake(0,0,SCREEN_WIDTH,SCREEN_HEIGHT)];
        [selfaddSubview:_scrollView];
       _scrollView.backgroundColor= [UIColorwhiteColor];
       //设置属性
       //设置滑动视图内容的大小
       _scrollView.contentSize=CGSizeMake(SCREEN_WIDTH*3,SCREEN_HEIGHT);
       //分页设置
       _scrollView.pagingEnabled=YES;
       //设置滚动条的显示与隐藏
       _scrollView.showsHorizontalScrollIndicator=NO;
       _scrollView.showsVerticalScrollIndicator=NO;
       
       //循环添加图片
       for(NSIntegeri =0; i <3; i++) {
           UIImageView*imageView = [[UIImageViewalloc]initWithFrame:CGRectMake(SCREEN_WIDTH* i,0,SCREEN_WIDTH,SCREEN_HEIGHT)];
           //设置属性
           NSString*imageName = [NSStringstringWithFormat:@"guide%@.jpg",@(i +1)];
            imageView.image= [UIImageimageNamed:imageName];
            imageView.userInteractionEnabled=YES;
     
           if(i ==2) {
     
               UIButton*button = [[UIButtonalloc]initWithFrame:CGRectMake(200,SCREEN_HEIGHT*0.85,SCREEN_WIDTH-400,SCREEN_HEIGHT*0.07)];
                [buttonsetTitle:@"立即体验"forState:UIControlStateNormal];
                button.titleLabel.font= [UIFontfontWithName:@"Helvetica-Bold"size:20];
                [buttonaddTarget:selfaction:@selector(didExperButton)forControlEvents:UIControlEventTouchUpInside];
               UIColor*color =UICOLOR_FROM_HEX(0x008aff);
                [buttonsetBackgroundColor:color];
                [imageViewaddSubview:button];
       
            }
           
            [_scrollViewaddSubview:imageView];
        }
    }
     
    - (void)didExperButton
    {
        [UIViewbeginAnimations:@"animation"context:nil];
        [UIViewsetAnimationDuration:1.0f];
        [UIViewsetAnimationCurve:UIViewAnimationCurveEaseInOut];
        [UIViewsetAnimationTransition:UIViewAnimationTransitionCurlUpforView:self.windowcache:YES];
        [UIViewcommitAnimations];
        [selfremoveFromSuperview];
    }
     
    @end
  • 相关阅读:
    超实用的PHP代码片段
    推荐五款优秀的PHP代码重构工具
    PHP开发搜索引擎技术全解析
    怎样成为一名PHP专家?
    PHP中该怎样防止SQL注入?
    有关PHP 10条有用的建议
    fir.im Weekly
    可能是一场很 IN 的技术分享
    fir.im Weekly
    更新日志
  • 原文地址:https://www.cnblogs.com/xuzb/p/8707007.html
Copyright © 2011-2022 走看看