我想知道如何将图像添加到整个屏幕上覆盖应用程序本身信息的应用程序。
这是要求:
示例(仅在iPad上找到一个,虽然我需要它用于iPhone):
我该怎么做?有没有我可以使用的免费框架?任何提示,信息或链接都非常感谢。
答案 0 :(得分:6)
- (void)viewDidLoad {
[super viewDidLoad];
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"didDisplayHelpScreen"]) {
UIWindow *window = [[[UIApplication sharedApplication] windows] lastObject];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:window.bounds];
imageView.image = [UIImage imageNamed:@"78-stopwatch"];
imageView.backgroundColor = [UIColor greenColor];
imageView.alpha = 0.5;
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissHelpView:)];
[imageView addGestureRecognizer:tapGesture];
imageView.userInteractionEnabled = YES;
[window addSubview:imageView];
}
}
- (void)dismissHelpView:(UITapGestureRecognizer *)sender {
UIView *helpImageView = sender.view;
[helpImageView removeFromSuperview];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"didDisplayHelpScreen"];
}
答案 1 :(得分:3)
在NSUserDefaults中定义一些BOOL键。如果为NO,则显示叠加并将其设置为YES。下次用户启动应用程序时,将跳过此步骤。
要添加图片以覆盖您的视图,代码将如下所示:
UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.view.frame];
imageView.image = [UIImage imageNamed:@"overlay image"];
[self.view addSubview:imageView];