![
![IMG_0076.PNG](http:https://img.haomeiwen.com/i1399153/d51d1a725770e01d.PNG?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
](http:https://img.haomeiwen.com/i1399153/d8df5fec7401c540.PNG?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
因项目首页是地图,而且我们的app名字是M-help,下载的人进去一脸“懵逼”,并不知道这个app是干嘛的,所以要求做一个“新手指引”,其实这个功能和引导页差不多用UIScrollView的contentSize和contentOffset(偏移量)这两个属性,需要的图让UI出好,我们只管显示就行了!!ok,话不多说,上代码,需要的可以直接拿过去~
代码在appdelegate里面写
// 移除引导页
-(void)removeLun
{
[scrollView removeFromSuperview];
newScrollView = [[UIScrollView alloc]initWithFrame:[UIScreen mainScreen].bounds];
[self.window.rootViewController.view addSubview:newScrollView];
[self.window.rootViewController.view bringSubviewToFront:newScrollView];
newScrollView.bounces = NO;
newScrollView.showsHorizontalScrollIndicator = NO;
newScrollView.showsVerticalScrollIndicator = NO;
newScrollView.pagingEnabled = NO;
NSArray *imageArr = @[@"新手引导-1.jpg",@"新手引导-2.jpg",@"新手引导-3.jpg"];
// 设置scrollview内容
for (int i = 0; i < 3; i++) {
UIImageView *bgImgView = [[UIImageView alloc]initWithFrame:CGRectMake(kScreenWidth * i, 0, kScreenWidth, kScreenHeight)];
[newScrollView addSubview:bgImgView];
bgImgView.userInteractionEnabled = YES;
bgImgView.image = [UIImage imageNamed:imageArr[i]];
[newScrollView addSubview:bgImgView];
UIButton *removeBtn1 = [[UIButton alloc] initWithFrame:CGRectMake(100, 100, 150, 100)];
removeBtn1.backgroundColor = [UIColor clearColor];
[bgImgView addSubview:removeBtn1];
removeBtn1.tag = 1230 + i;
[removeBtn1 mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(bgImgView);
make.width.mas_equalTo(150);
make.height.mas_equalTo(80);
}];
[removeBtn1 addTarget:self action:@selector(removeNewScroll:) forControlEvents:UIControlEventTouchUpInside];
}
newScrollView.contentSize = CGSizeMake(kScreenWidth * 3, kScreenHeight);
newScrollView.contentOffset = CGPointMake(0, 0);
}
-(void)removeNewScroll:(UIButton *)btn {
if (btn.tag == 1232) {
[newScrollView removeFromSuperview];
}else {
newScrollView.contentOffset = CGPointMake(kScreenWidth * (btn.tag - 1230 + 1), 0);
}
}```
####最后宣传一下我们的app,名字M-help,是个帮助类的app,不管你有什么困难和问题都可以在我们平台上面发,但是需要一定报酬给解决你困难的人,现在上线的版本是测试版,有很多bug,大神无喷,在努力修复中,后续也有很多新的功能,感兴趣的可以下载一下,谢谢大家!!!
网友评论