创建点击覆盖指令视图 [英] Create click-through overlay instruction view
问题描述
这是一个非常简单的问题。
如何创建这样的视图?
A really simple question here. How do you create a view like this?
它必须覆盖第一次用户运行应用程序的这一部分,并在用户点击它时永久删除。我知道它应该是一个UIImageView,但你怎么把它激活,然后永远将它从视图中删除?
It has to overlay the first time user runs this part of the app and be removed forever once the user taps on it. I understand it should be a UIImageView, but how do you make it active and then remove it from the view forever?
推荐答案
你您可以使用 addSubView
方法在应用程序代理的 didFinishLaunchingWithOptions
方法中添加您的子视图 UIView
class。以下是一些如何继续的代码片段:
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];
}
请注意,您需要一个属性来引用<$ c中的imageView $ c> handleTap 方法。
Note that you will need a property to reference your imageView in the handleTap
method.
这篇关于创建点击覆盖指令视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!