I want to remove the default white background of UITableViewCell like I want the background of the cell being transparent so that it shows the actual background of the window.
I Got it.
UIView *backView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
backView.backgroundColor = [UIColor clearColor];
cell.backgroundView = backView;
Related
I created a UITableView. I gave it a background image like this:
UIImageView *imageview1 = [[UIImageView alloc] init];
imageview1.image = [UIImage imageNamed:#"blood2.gif"];
evc.tableView.backgroundView = imageview1;
And then I made the cells translucent by changing them in the tableView:cellForRowAtIndexPath: method:
UIView *backgrView = [[UIView alloc] initWithFrame:CGRectZero];
backgrView.backgroundColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:0.7];
cell.backgroundView = backgrView;
But now there are no borders around the UITableViewCells anymore. I already set the separatorColor to black but the borders won't show up...
Check with this
[cell.contentView.layer setBorderColor:[UIColor redColor].CGColor];
[cell.contentView.layer setBorderWidth:2.0f];
I have a custom UITableView with its clearColor background. I'm setting the cell's backgroundView to a transparent UIImageView and setting the background image view's backgroundColor to [UIColor clearColor]. I'm also setting the cell's backgroundColor to [UIColor clearColor].
I want to make cell.backgroundview as transparent on selection. How to do that?
you can explicitly set a selectedBackgroundView property of the cell with a semitransparent or transparent content (UIimageview) so that i will not become opaque on selection
http://www.youtube.com/watch?v=PwcBdCUZNWs
i think thats what u r asking for just make the selectedView transparent from the UI properties
In your Cell creation :
cell.selectedBackgroundView =[[UIImageView alloc] init];
((UIImageView *)cell.selectedBackgroundView).image = [UIImage imageNamed:#"your transparent UIImage"];
or:
UIView *v = [[UIView alloc] init];
v.backgroundColor = [UIColor clearColor];
cell.selectedBackgroundView = v;
I've added custom background image to my UITableView and it shows fine. Than, i removed any background color from the cells. Now i expect to see only cells' text on top of table's background image, however i see strange behaviour. Cells take pattern color of table's background image, so that i see waves like in the picture:
The background image shell look like this:
*pay attention to white circles that disappear under the cells!
My code is as follws:
in viewDidLoad i set the background image of table view:
self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"general_bg.png"]];
For each cell i remove any background color like this:
UIView *bckView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
bckView.backgroundColor = [UIColor clearColor];
cell.backgroundView = bckView;
cell.backgoundColor = [UIColor clearColor];
cell.contentView.backgroundColor = [UIColor clearColor];
UILabel *textLabel = [[UILabel alloc] initWithFrame:CGRectMake(x,y,x1,y1)];
textLabel.backgroundColor = [UIColor clearColor];
[cell.contentView addSubview:textLabel];
line separators are custom images added to cells.
Instead of setting the BackgroundColor attribute of the tableview, try setting the backgroundview:
UIView *background = [[UIView alloc] initWithFrame:self.tableView.bounds];
background.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"YOUR_IMAGE.png"]];
self.tableView.backgroundView = background;
This should fix the issue of the cell's taking on the same image as the background.
self.tableView.backgroundView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"YOUR_IMAGE.png"]];
maybe this is what you're looking for
I have a tableview in grouped style. When I set the tableview background color to clear color then I see dark black corners around the tableview. Is there a way to solve this problem and remove those dark corners?
Any help would be appreciated.
Along with using clearColor, use the following:
[tableView setBackgroundView:nil];
[tableView setBackgroundColor:[UIColor clearColor]];
[tableView setOpaque:NO];
You can set a UIView and set clear color to it. This works for me.
UIView *backView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
backView.backgroundColor = [UIColor clearColor];
cell.backgroundView = backView;
I hope to add image to cell background and from the semi transparent cell I could see the backgroud of tableview.
From following topic, I know how to make transparent cell.
UITableViewCell transparent background (including imageView/accessoryView)
I've tried above, it did work. But when I add the following code:
UIView *backView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
backView.backgroundColor = [UIColor colorWithRed:.1 green:.1 blue:.1 alpha: .4];
cell.backgroundView = backView;
The cell became grey color without any transparency, if I change code as follows,
UIView *backView = [[UIView alloc] initWithFrame:CGRectZero];
backView.backgroundColor = [UIColor clearColor];
cell.backgroundView = backView;
The cell became white, still without any transparency.
Is there one can give me any clues?
To make your UITableViewCells Semi-Transparent that is Translucent, you have to make your UITableViewCells Transparent and then, set cell's backgroundView to an image which has translucent properties. Also set selectedBackgroundView of the cell to an image which is translucent and gives a selected cell's effect.
UIView *backView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
backView.backgroundColor = [UIColor clearColor];
cell.text.backroundColor = [UIColor clearColor]; //if you have labels on cells..
cell.backgroundView = backView;
Then set an image with translucent effect on our transparent cell..
UIImageView *cellImage = [[UIImageView alloc] init];
[cellImage setImage:[UIImage imageNamed: #"unselectedCellImage.png"]];
[cell setBackgroundView:cellImage];
[cellImage release];
Then set an image for selected cell to give an translucent effect after selection also..
UIImageView *cellImageSelection = [[UIImageView alloc] init];
[cellImageSelection setImage:[UIImage imageNamed: #"selectedCellImage.png"]];
[cell setSelectedBackgroundView:cellImageSelection];
[cellImageSelection release];
It'll work..
Cheers..
You can try this one
UIView *backView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
backView.backgroundColor = [UIColor colorWithRed:255 green:255 blue:255 alpha: .2];
cell.backgroundView = backView;
What you did wrong was you choose .1 .1 .1 which is for black color you need 255 255 255 for the white color and your opacity was very high so it looked gray color to you actually it was black with opacity. Hope this helps :)
Views are initialized as opaque by default, so you probably need to explicitly set backView.opaque = NO; in order for it to draw with any transparency.