gpt4 book ai didi

objective-c - 所有UI前面的透明UIImageView

转载 作者:塔克拉玛干 更新时间:2023-11-01 19:12:21 25 4
gpt4 key购买 nike

在我的应用程序首次启动后,我想向用户展示一个小教程,以解释我的应用程序的功能。

所以我需要设置一个带有一些箭头和标签的透明 UIImageView,其中主 UI(更具体地说,tabbarcontroler 中的 navigationviewcontroller 中的 tableviewcontroller)在教程图像后面仍然可见。

而且,因为教程由多张图片组成,所以我想添加一个点击手势来切换到另一张图片。

我只是尝试将一个 UIImageView 添加到我的 tabbarcontroller,并为其添加一个手势识别器,但它对我的点击没有反应,它只是工作,就像没有 ImageView - 选择表格中的鱼子,插入按钮。

   -(void)nextTap:(UIGestureRecognizer*)nextTap
{
//Show another image
}
-(void)showTutorial
{
NSLog(@"Show tutorial");
UIImageView *tutorialImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"BG"]];
[self.navigationController.tabBarController.view addSubview:tutorialImage];
UITapGestureRecognizer *nextTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(nextTap:)];
[tutorialImage addGestureRecognizer:nextTap];
}

谁能告诉我,我应该在哪里添加我的 View 才能正常工作?

最佳答案

用另一个 UIWindow 做!

像这样:

-(void)showTutorial
{
NSLog(@"Show tutorial");


CGRect screenBounds = [UIScreen mainScreen].bounds;
UIWindow *anotherWindow = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, screenBounds.size.width, screenBounds.size.height)];
anotherWindow.windowLevel = UIWindowLevelAlert+1;
[anotherWindow makeKeyAndVisible];

// make the background of the new window black alpha 0.5
anotherWindow.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];

// add a test-image (icon)
UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon.png"]];
[anotherWindow addSubview:image];

UIImageView *tutorialImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"BG"]];
[anotherWindow addSubview:tutorialImage];
UITapGestureRecognizer *nextTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(nextTap:)];
[tutorialImage addGestureRecognizer:nextTap];
}

已编辑!现在它也应该适用于您的情况。

关于objective-c - 所有UI前面的透明UIImageView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10041854/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com