3

UIPresentModalViewController view alpha is not configured

 2 years ago
source link: https://www.codesd.com/item/uipresentmodalviewcontroller-view-alpha-is-not-configured.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

UIPresentModalViewController view alpha is not configured

advertisements

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


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?


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK