1

Here's my problem: I've actually created a custom segue to manage in a different way the transitions between my UIViewControllers (I'm working on a Storyboard based project). I added some animations using CATransform3D to move the views...so...when I do that, the only thing I can see in the background is a black view.

I would love to know how to change that color and if is possible to replace it with a UIImageView. Do you have any trick/idea to do that?

Thanks! :)

enter image description here

Sara Canducci
  • 6,231
  • 5
  • 19
  • 24
  • Can you post your view setup? (A screenshot of the storyboard or so). Anyway you can try to access `self.window.rootViewController` and add a subview there. – Sebastian Wramba Jul 03 '14 at 11:41
  • http://stackoverflow.com/a/6131321/581994 – Hot Licks Jul 03 '14 at 11:46
  • @SebastianWramba I tried this even though it's not working :( --> SecondViewController *secV = [[SecondViewController alloc] init]; secV.view.backgroundColor = [UIColor greenColor]; [[UIApplication sharedApplication].keyWindow.rootViewController addChildViewController:secV]; – Sara Canducci Jul 03 '14 at 11:53
  • @SebastianWramba Just added a screenshot – Sara Canducci Jul 03 '14 at 11:58

2 Answers2

0

You can try following if you are sure the black view is a root controller's view:

UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"my_image"]];
UIView *rootView = [[UIApplication sharedApplication].keyWindow.rootViewController.view];
[rootView insertSubview:imageView atIndex:0];
Alex Peda
  • 4,210
  • 3
  • 22
  • 31
  • Just tried your code...but it still shows the black screen in the background...does it mean that what I see is not the rootView? If so...how can I access it? – Sara Canducci Jul 03 '14 at 13:04
  • Have you tried to change rootView bg color? Window bg color? It will be great to clarify your views stack. Try to change bg color of your navigation controller please – Alex Peda Jul 03 '14 at 14:03
0

Actually,this is a grave, but I would leave the answer for later-comers.

We know that iOS is migrated from OS X, so all viewControllers are in UIWindow, the black color is the backgroundColor of the window. so that you should not find any root viewController, what you find is the top window.

if you want to change the black backgroundColor to other color, like white, do:

  UIWindow *window = [[UIApplication sharedApplication].windows lastObject];
  window.backgroundColor = [UIColor whiteColor];
XOQ
  • 1
  • 1