代码如下
#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(,,SCREEN_WIDTH,SCREEN_HEIGHT)];
[selfaddSubview:_scrollView];
_scrollView.backgroundColor= [UIColorwhiteColor];
//设置属性
//设置滑动视图内容的大小
_scrollView.contentSize=CGSizeMake(SCREEN_WIDTH*,SCREEN_HEIGHT);
//分页设置
_scrollView.pagingEnabled=YES;
//设置滚动条的显示与隐藏
_scrollView.showsHorizontalScrollIndicator=NO;
_scrollView.showsVerticalScrollIndicator=NO; //循环添加图片
for(NSIntegeri =; i <; i++) {
UIImageView*imageView = [[UIImageViewalloc]initWithFrame:CGRectMake(SCREEN_WIDTH* i,,SCREEN_WIDTH,SCREEN_HEIGHT)];
//设置属性
NSString*imageName = [NSStringstringWithFormat:@"guide%@.jpg",@(i +)];
imageView.image= [UIImageimageNamed:imageName];
imageView.userInteractionEnabled=YES; if(i ==) { UIButton*button = [[UIButtonalloc]initWithFrame:CGRectMake(,SCREEN_HEIGHT*0.85,SCREEN_WIDTH-,SCREEN_HEIGHT*0.07)];
[buttonsetTitle:@"立即体验"forState:UIControlStateNormal];
button.titleLabel.font= [UIFontfontWithName:@"Helvetica-Bold"size:];
[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