Question

I am wondering how I can add an image to the app that overlays the whole screen with information about the app itself.

This are the requirements:

  • Only show once on first start
  • Cover the whole screen (including tabbar and navigationbar)
  • When user clicks on image, it should fade away and never appear again ;)

Example (Only found one on iPad, although I need it for the iPhone):

enter image description here

How can I do this? Are there any free frameworks I can use? Any hints, information or links are much appreciated.

Was it helpful?

Solution

  1. Check NSUserDefaults if the help view was displayed (and dismissed) before
  2. Create UIImageView and add it to your view
  3. Add UITapGestureRecognizer to the imageView
  4. in the action of the tap gesture remove the help view and save to NSUserDefaults that the view was dismissed.

.

- (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"];
}

OTHER TIPS

Define some BOOL key in NSUserDefaults. If it is NO, then show your overlay and set it to YES. Next time user starts the app, this step will be skipped.

To add an image to cover your view, code will look something like this:

UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.view.frame];
imageView.image = [UIImage imageNamed:@"overlay image"];
[self.view addSubview:imageView];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top