views:

65

answers:

2

I'm setting the background color of my UIView (which is within a UIViewController) as follows:

myView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"myTransparentBG.png"]];

I've even tried messing with [myView setOpaque:NO]; but the image doesn't appear transparent. It has a black background to it. Am I abel to fix this programmatically? Otherwise, how are we supposed to set a transparent background to our view?

This seems like a question that should have been asked before, but I couldn't find an answer.

A: 

Use this: myView.backgroundColor = [UIColor clearColor];

This will set it to a transparent background.

Istvan
On it? I want the image to be the background. I have other UI elements inside the view.
RyanJM
If u set the UIView color to clearColor, then it will be transparent. Depending where the images and other views are ordered, you can play around with them.
Istvan
A: 

I haven't ever actually done this, but here's what I'd try.

Set the UIView's .backgroundColor to [UIColor clearColor]. Then put a UIImageView containing your PNG as the "lowest" item on the UIView's stack of subviews. Make sure the UIImageView's background color is also clear.

Dan Ray