【问题标题】:How to add image over whole screen [duplicate]如何在整个屏幕上添加图像[重复]
【发布时间】:2013-08-30 11:13:34
【问题描述】:

我正在尝试从viewDidLoad 将覆盖图像放在整个 iPhone 屏幕上(也通过 导航tabbar),但没有任何反应。

self.imageView = [[UIImageView alloc]
                              initWithImage:[UIImage imageNamed:@"overlayimage.png"]];
UIWindow* window = [[UIApplication sharedApplication] keyWindow];
    [window.rootViewController.view addSubview: imageView];

UITapGestureRecognizer * recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
    recognizer.delegate = self;
    [imageView addGestureRecognizer:recognizer];
    imageView.userInteractionEnabled =  YES;
    self.imageView = imageView;

这是我想要得到的结果:

【问题讨论】:

  • 如果想要有闪屏,需要新建UIViewControoler
  • 是的,我有启动画面。但仍然无法在整个屏幕上添加图像。
  • 那你为什么不使用 UIIMagePicerViewController 呢?
  • @iPatel 为什么要删除我只想接受的答案?
  • @1110- 我的回答对你有帮助吗?其他明智的使用 UIImagePickerViewController :)]

标签: iphone ios objective-c ios6 uiimageview


【解决方案1】:

由于UIWindowUIView 的子类,您还可以将子视图添加到关键窗口。
这些子视图将出现在任何视图控制器之上。

UIWindow *keyWindow = [[[UIApplication sharedApplication] delegate] window];
[keyWindow addSubview:imageView];

【讨论】:

    【解决方案2】:
    imageView.frame = [[UIScreen mainScreen] applicationFrame];
    [self.navigationController.view addSubview: imageView];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-03-22
      • 1970-01-01
      • 1970-01-01
      • 2018-06-08
      • 2021-04-11
      • 2021-02-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多