iOS 添加功能引导图

时间:2021-12-28 06:02:36

iOS 添加功能引导图

首次安装app之后,打开app首页,有一张功能引导图,其实最简单的一种做法是,直接在这个首页上加一个蒙层图片。

在蒙层上用气泡显示文字注明功能介绍,这个蒙层图片,让你们的UI设计师给你。
iOS 添加功能引导图

然后在进入首页的viewDidAppear方法里,添加上你的蒙层

[self initIntroduceView];

下面是添加的简单示例代码:

示例

- (void)initIntroduceView

{

if (![USERDEFAULT objectForKey:@"IsShowIntro"]) {

UIImageView *introImg = [[UIImageView alloc] initWithFrame:self.view.bounds];

introImg.tag = INTRO_TAG;

introImg.userInteractionEnabled = YES;

if (iPhone4S) {

introImg.image = [UIImage imageNamed:@"explanation_960"];

}

else

{

introImg.image = [UIImage imageNamed:@"explanation"];

}

[self.tabBarController.view addSubview:introImg];

UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(removeIntroImg)];

tap.numberOfTapsRequired = ;

[introImg addGestureRecognizer:tap];

}

}

- (void)removeIntroImg

{

[USERDEFAULT setObject:[NSNumber numberWithBool:YES] forKey:@"IsShowIntro"];

UIImageView *imgView = (UIImageView *)[self.tabBarController.view viewWithTag:INTRO_TAG];

[imgView removeFromSuperview];

}

关于几个宏

#define USERDEFAULT [NSUserDefaults standardUserDefaults]

#define iPhone4S ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)

#define INTRO_TAG 50000