
](http://upload-images.jianshu.io/upload_images/1399153-d8df5fec7401c540.PNG?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
因項(xiàng)目首頁是地圖,而且我們的app名字是M-help,下載的人進(jìn)去一臉“懵逼”,并不知道這個(gè)app是干嘛的,所以要求做一個(gè)“新手指引”,其實(shí)這個(gè)功能和引導(dǎo)頁差不多用UIScrollView的contentSize和contentOffset(偏移量)這兩個(gè)屬性,需要的圖讓UI出好,我們只管顯示就行了!!ok,話不多說,上代碼,需要的可以直接拿過去~
代碼在appdelegate里面寫
// 移除引導(dǎo)頁
-(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 = @[@"新手引導(dǎo)-1.jpg",@"新手引導(dǎo)-2.jpg",@"新手引導(dǎo)-3.jpg"];
// 設(shè)置scrollview內(nèi)容
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,是個(gè)幫助類的app,不管你有什么困難和問題都可以在我們平臺(tái)上面發(fā),但是需要一定報(bào)酬給解決你困難的人,現(xiàn)在上線的版本是測(cè)試版,有很多bug,大神無噴,在努力修復(fù)中,后續(xù)也有很多新的功能,感興趣的可以下載一下,謝謝大家?。?!