I have a UITableViewController that has a background image. I am setting the image for the tableview like this:
[self.view setBackgroundColor: [UIColor colorWithPatternImage:
[UIImage imageWithContentsOfFile:
[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:
#"background1.jpg"]]]];
The problem is, each of my custom tableview cells get the same background image--it's repeated in each cell. As a test, I tried making everything in my cell transparent with an alpha of 0.0, but even then although I can't see any of the labels in each cell, I still see the background image repeated in each cell:
cell.backgroundColor = [UIColor clearColor];
cell.contentView.backgroundColor = [UIColor clearColor];
cell.contentView.alpha = 0.0;
cell.alpha = 0.0;
Any suggestions on how to get my table's background image to stop repeating in each cell would be appreciated!
Have you tried setting the opaque property to NO? It's defined in NSView.
[cell setOpaque:NO];
It's defined in the Apple API as follows:
YES if it is opaque; otherwise, NO. If
opaque, the drawing operation assumes
that the view fills its bounds and can
draw more efficiently. The results are
unpredictable if opaque and the view
doesn’t fill its bounds. Set this
property to NO if the view is fully or
partially transparent. The default
value is YES.
Related
Is there a way such that I can set the alpha of a UILabel, but it doesn't fade out the text of the UILabel? Meaning just the background?
As the text is a part of the label, if you set the alpha for the label the text fades appropriately. What you want is to set a backgroundColor with the appropriate alpha:
myLabel.backgroundColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:0.5];
You may have to create a background view (UIView will suffice), and put the UILabel on top (not as a subview, because the alpha value of the background view affects all of its subviews)
I am creating an iOS application in which I have added a simple UIImage. I want to add the transparency effect in image to show other images behind that main image. Tell me how I can achieve this effect?
Note: I don't want to change the opacity/alpha of image.
An alpha change is how you alter transparency. In addition to this, you would want to alter this on the view level not on to the UIImage directly. E.x:
[myImageView setImage:[UIImage imageNamed#"myImage.png"]];
[myImageView setAlpha:0.7f];
use images in png format with alpha channel in it: alpha channel is the layer that tells how many transparent each pixel is
how about this:
self.imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f,0.0f,1024.0f,768.0f)];
self.imageView.backgroundColor = [UIColor colorWithRed:255 green:255 blue:255 alpha:0.5];
[self.view addSubview:self.imageView];
or set its alpha
imageView.alpha = 0.5;
But be sure to instantiate the imageView, as property then synthesize.
u build an UIView and put an image as the view backgrond:
self.tmpView = [[UIView alloc] initWithFrame:CGRectMake(20, 70, 280, 295)];
self.tmpView.backgroundColor = [UIColor yellowColor];
self.tmpView.backgroundColor = [UIColor clearColor];
self.tmpView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"CloseUPPicBG.png"]];
the problem is that theuiview is now with corners in black color.
the image that i put as backgrond is with rounded corners.
any solution for this?
Edit the image to not have rounded corners, or so that the space behind the corners is some other color or image.
What you're doing is saying
View, be yellow.
View, be clear. What's behind you? Nothing. Ok, be black.
View, fill yourself with this image.
View is then thinking
Hmm... there's transparency in this image.
Guess I should show whatever's behind me. Which is nothing... So black.
self.tmpView.opaque = NO;
might help.
hello i have a UIimageView with a PNG image that has round corners, image sits fine the only problem it has is that i can see the UIImage Corners with a white background, how can I make the background clear and transparent.
Try this:
imageView.backgroundColor = [UIColor clearColor];
imageView.opaque = NO;
You can achieve the same thing in IB by making the 'Background' a color with 0% opacity, and unticking the 'Opaque' checkbox.
try
imageView.backgroundColor = [UIColor clearColor];
I subclassed a subview and added it to the current view. It draws a simple circle by overriding the draw method.
But the subview has a black background it looks like by default. How do I make the background of my subclassed subview to be transparent?
does
self.backgroundColor = [UIColor clearColor] not work?
You can call next code into view initialization:
self.backgroundColor = [UIColor clearColor];