標籤:
@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