Create click-through overlay instruction view

后端 未结 3 550
北海茫月
北海茫月 2020-12-30 14:21

A really simple question here. How do you create a view like this? \"enter

It has to

相关标签:
3条回答
  • 2020-12-30 14:31

    You can add your subview just after your app launch in the didFinishLaunchingWithOptions method of your app delegate by using the addSubView method of the UIView class. Here are some code snippets of how you could proceed:

    - (BOOL)application:(UIApplication *)application 
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {  
    
        UIImageView *imageView = [[UIImageView alloc] 
        initWithImage:[UIImage imageNamed:@"yourimage.png"]];
        [self.window addSubview:imageView];
    
         UITapGestureRecognizer * recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
         recognizer.delegate = self;
        [imageView addGestureRecognizer:recognizer];
        imageView.userInteractionEnabled =  YES;
        self.imageView = imageView;
    }
    
    - (void) handleTap:(UITapGestureRecognizer *)recognize
    {
         [self.imageView removeFromSuperView];
    }
    

    Note that you will need a property to reference your imageView in the handleTap method.

    0 讨论(0)
  • 2020-12-30 14:44

    UIView has all the methods you need, e.g.

    • Call [myView addSubview:imgView] to add the image view to the current view (myView)
    • Call [imgView removeFromSuperview] when finish (i.e. in respond to tap or after a timer)

    Make sure userInteractionEnabled property of imgView to NO so that touches are passed to myView.

    0 讨论(0)
  • 2020-12-30 14:45

    My thoughts would be set an NSUserDefault variable and check it on applicationDidFinishLaunchingWithOptions or somewhere else in your app that makes sense. You could just push a separate view when your variable is true vs. false.

    0 讨论(0)
提交回复
热议问题