1

I want to present a view controller where I have one Background imageView. Alpha for that imageview is 0.5 (want to add as semi-transperant black image so). But when I present that view controller that alpha doesn't work for view. That image entirely looks blackish, like alpha has not been even set.

This issue is there for iPad device only.

Please help me out.

Code:
ViewController1.m:
[self presentModalViewController:viewController2];

ViewController2.xib: (in nib I am setting below values no in code)
[self.view setBackgroundColor:[UIColor clearColor]];
[self.bgImageView setAlpha:0.5]; // this image is dark black, i want to display the 

content of the screen which is behind this (viewController1.view), kind of semi-transperancy

I tried one more thing, this time i have removed imageView and set uiview bgcolor to black, opaque=NO, alpha=0.2 (in nib itself). So while animation of presenting it looks perfect. But when view has been placed it turns into alpha=1.0 (complete black)

Still there is no transparency where am i wrong over here.

Answer Is Here: There is some bug/limitation with ModalViewController so its better to go with addSubview for such situation

Community
  • 1
  • 1
Mrunal
  • 13,982
  • 6
  • 52
  • 96
  • Post some code, make it easier to help you... – Peter Sarnowski Feb 18 '12 at 12:28
  • i don't sure a modal viewcontroller may have a transparent self.view – NeverBe Feb 18 '12 at 12:37
  • try seting opaque to NO in ViewController2.xib for view and bgImageView. NeverBe might also be right, there's a similiar problem with UIPopoverViewController – Rok Jarc Feb 18 '12 at 12:38
  • you might try to present it non-modal so you will know if the problem is in modality or in your code – Rok Jarc Feb 18 '12 at 12:43
  • I tried, this time i have removed image and set uiview bgcolor to black, opaque=NO, alpha=0.2. so while animation of presenting it looks perfect. But when view has been placed it turns into alpha=1.0 (complete black) – Mrunal Feb 18 '12 at 12:43
  • 1
    You might find your answers here: [Transparent Modal View on Navigation Controller][1] [1]: http://stackoverflow.com/questions/849458/transparent-modal-view-on-navigation-controller – Rok Jarc Feb 18 '12 at 12:47

2 Answers2

0

Answer Is Here: There is some bug/limitation with ModalViewController so its better to go with addSubview for such situation

Community
  • 1
  • 1
Mrunal
  • 13,982
  • 6
  • 52
  • 96
0

Try to write imageview.alpha = 0.5 after you present the modelviewcontroller and see what happens. Just give it a try.

EDIT: 1)Clean Build and Run

The image alpha you are trying to set, is it in viewcontroller that you are presenting from or is it in modalviewcontroller?

Rajashekar
  • 619
  • 9
  • 30
  • Yes I have tried that also in viewDidLoad, so after loading view I was trying to set it. But not working, its seems really weird not getting the reason? – Mrunal Feb 18 '12 at 12:38