引导页实现代码--iOS

Posted PJXWang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了引导页实现代码--iOS相关的知识,希望对你有一定的参考价值。

 

@interface PJXPushGuideView : UIView

+(instancetype)guideView;

+(void)show;

@end

 

#import "PJXPushGuideView.h"

 

@implementation PJXPushGuideView

 

+(instancetype)guideView{

    //加载xib

    PJXPushGuideView *guideView = [[[NSBundle mainBundle]loadNibNamed:NSStringFromClass(self) owner:nil options:nil] lastObject];

    guideView.backgroundColor = [UIColor colorWithRed:49.0/255.0 green:49.0/255.0  blue:49.0/255.0  alpha:0.75];

    return guideView;

}

- (IBAction)remove:(id)sender {

    [self removeFromSuperview];

}

+(void)show

{

    NSDictionary *info = [[NSBundle mainBundle]infoDictionary];

    NSString *key = @"CFBundleShortVersionString";

    NSString * currentVersion = [info objectForKey:key];

    NSString *sanboxVersion = [[NSUserDefaults standardUserDefaults] stringForKey:key];

    if (![currentVersion isEqualToString:sanboxVersion]) {

        PJXPushGuideView *pushView = [PJXPushGuideView guideView];

        pushView.frame = [UIApplication sharedApplication].keyWindow.bounds;

        [[UIApplication sharedApplication].keyWindow addSubview:pushView];

        [[NSUserDefaults standardUserDefaults] setObject:currentVersion forKey:key];

        [[NSUserDefaults standardUserDefaults] synchronize];

        

    }

 

}

@end

 然后在PJXPushGuideView.xib中实现控件布局

以上是关于引导页实现代码--iOS的主要内容,如果未能解决你的问题,请参考以下文章

[iOS] App引导页的简单实现 (Swift 2)

iOS App引导页功能实现

iOS 启动页和引导页的分割适配法

iOS引导页动画(封装好)

【iOS_GitHub】引导页/首次安装引导页/渐变引导页/APP介绍页/新功能介绍页

iOS - GitHub干货分享(APP引导页的高度集成 - DHGuidePageHUD - ②)