Transparent .png not transparent in iOS 4, looks fine in iOS 5

Take a look:

This is the code I use to make the gradient:

gradView = [[UIView alloc] initWithFrame:CGRectMake(0, 440, self.view.frame.size.width, 80)];
gradView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"sepGrad.png"]];
gradView.alpha = 0.2;
[self.view addSubview:gradView];

And the .png files:

Why would iOS4 be unable to display the transparent .png properly?

Answers


I think it's a bug in iOS 4.3, see this answer: https://stackoverflow.com/a/8896838/429331

In your case:

gradView = [[UIView alloc] initWithFrame:CGRectMake(0, 440, self.view.frame.size.width, 80)]; 
gradView.opaque = YES;
gradView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"sepGrad.png"]];
gradView.opaque = NO;
gradView.alpha = 0.2;
[self.view addSubview:gradView];

You could also try to omit gradView.opaque = YES;, I'm not sure if it's really necessary.


Need Your Help

Aligning Android Button To Bottom in RelativeLayout?

android button alignment

I'm trying to align a button to the bottom right and bottom left of my screen, using a RelativeLayout. I want to do this to keep the same relative layout across different screen sizes. Currently, ...

iAd banner shows empty black space after dismissing modal view

ios uitableview iad uistoryboardsegue candisplaybannerads

My app shows banner ads at the bottom of UIViewController which is root view using self.canDisplayBannerAds = true in viewDidLoad(). App has a settings view which is a UITableViewController and i am