0

Can I reveal the underlying view (or the view at the back of a view controller), by making a view controller's view transparent? I tried and it just fades to black and doesn't reveal anything behind it.

Reason?

EDIT: Okay, this question needs more context. I have a view controller. Now I am going to present another view controller(simple presentation of view controller, modally). After the new view controller has been presented, I am making its view transparent with alpha=0. Why does it not reveal the underlying view controller's view?

Will using the iOS 7 Transition API help?

esh
  • 2,842
  • 5
  • 23
  • 39
  • Provide some more context about your view controller hierarchy and we can provide a more useful answer. How is your view controller presented? Is it presented modally? Is it a child view controller of a navigation controller or a tab bar controller? Etc., etc. – Jasarien Apr 23 '14 at 09:18
  • 1
    doing `[self.view setAlpha:0.0f];` will make everything disappear, even it's subviews. try `[self.view bringSubviewToFront:underlyingView];` instead – staticVoidMan Apr 23 '14 at 09:19
  • if you're doing `-presentViewController:animated:completion:` then the `presentingViewController` is hidden from the view hierarchy. [see: similar question](http://stackoverflow.com/a/587916/2857130) – staticVoidMan Apr 23 '14 at 09:27
  • @BlackFlam3: You should have to travel through the objective-C basic architechture. – Vineesh TP Apr 23 '14 at 09:28

3 Answers3

2

If you present your view controller modally (using presentViewController:animated:completion:) then the presenting view controller's view will be removed removed from the window, therefore you cannot see through your presented view controller to the presenting view controller. You might want to use child view controller: https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/CreatingCustomContainerViewControllers/CreatingCustomContainerViewControllers.html

Alternatively, you can present your view controller inside a new UIWindow.

JonasG
  • 9,274
  • 12
  • 59
  • 88
1

You cannot see the original view controller because you use -presentViewController:animated:completion: which will hide the presenting view controller after the animation finished.

You can set the modalPresentationStyle to one of UIModalPresentationOverCurrentContext, UIModalPresentationOverFullScreen and UIModalPresentationCustom before you called 'presentViewController:animated:completion' so that the underlying presenting view controller will not be hidden.

0

If you would like to have the same background image showing below all UIViewController you can add a UIImageView to the [UIApplication sharedApplication].window in the applicationdidfinishlaunching method

clevin
  • 79
  • 3