标签:eve border UI count lin tle root ica first
//第一次安装时会有引导页展示 非第一次直接进入应用页
if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"isOne"] isEqual:@"isOne"]) {
[self showViewController];
}else{
RootViewController *root= [[RootViewController alloc] init];
self.window.rootViewController = root;
[self isFirstInstall];
}
//直接在AppDelegate 类中写该方法
-(void)isFirstInstall{
//引导页
UIScrollView *sc = [[UIScrollView alloc]initWithFrame:self.window.bounds];
sc.pagingEnabled = YES;
sc.delegate = self;
sc.showsHorizontalScrollIndicator = NO;
sc.showsVerticalScrollIndicator = NO;
[self.window.rootViewController.view addSubview:sc];
NSArray *arr = @[@"引导页1.jpg",@"引导页2.jpg",@"引导页3.jpg"];
for (NSInteger i = 0; i<arr.count; i++)
{
UIImageView *img = [[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH*i, 0, SCREEN_WIDTH, self.window.frame.size.height)];
img.image = [UIImage imageNamed:arr[i]];
[sc addSubview:img];
img.userInteractionEnabled = YES;
if (i == arr.count - 1)
{
//根据自己项目中的需求进行设置末页体验按钮
UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
btn.frame = CGRectMake((self.window.frame.size.width/2)-100, SCREEN_HEIGHT-110, 200, 50);
// btn.backgroundColor = [UIColor greenColor];
// [btn setTitle:@"开始体验" forState:UIControlStateNormal];
[btn addTarget:self action:@selector(goRoot) forControlEvents:UIControlEventTouchUpInside];
[img addSubview:btn];
[btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
// btn.layer.borderWidth = 1;
// btn.layer.borderColor = [UIColor greenColor].CGColor;
}
}
sc.contentSize = CGSizeMake(SCREEN_WIDTH*arr.count, self.window.frame.size.height);
}
//立即体验的执行方法
- (void)goRoot{
NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
[user setObject:@"isOne" forKey:@"isOne"];
[user synchronize];
//在这里设置项目中的根控制器
self.window.rootviewController = viewcontroller ;
}
//项目中scrollview的代理方法设置引导页
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
//SCREEN_WIDTH *4 这里4是引导页的张数,x的偏移量大于4个屏幕多30,也可以进入应用,类似立即体验中的功能方法。根据自己项目中的需求进行添加
if (scrollView.contentOffset.x>SCREEN_WIDTH *4+30)
{
[self goRoot];
}
}
//就是这么easy,引导图设置完毕,共勉
标签:eve border UI count lin tle root ica first
原文地址:http://www.cnblogs.com/tryFighting/p/6480163.html