I have a view that contains a scroll view and again that contains a view and then a table view.(this table view has custom cells).
I have a background image for the top most view but the inner most table view background is blocking the image. Tableview shows a white background .
I have to make the background of tableview as transparent so that the image on the view should be visible.
how to do that. Pls help.
Try:
tableView.backgroundView = nil;
tablecell.contentview.backgroundcolor = [UIColor clearColor];
Hope it should help..
You have to set the backgroundview nil before making background as transparent
tableView.backgroundView = nil;
tableView.backgroundColor=[UIColor clearColor];
Related
I have a collection view and of course I also have the cells in it. If in the property inspector I change the alpha of collection view to 0, the cells in it also become transparent. Is there a way to make the background transparent of the collection view only so the image behind it is visible?
using in Swift 3:
collectionView.backgroundColor = UIColor.clear.withAlphaComponent(0)
You can change the cell colour to clear and set the background to nil to see whats underneath the collectionView. Like this:
collectionview.backgroundView = nil;
collectionview.backgroundColor = [UIColor clearColor];
A UICollectionViewCell's background is defaulted to clear. Simply set a background colour for your cells either in interface builder or in a subclass using:
self.backgroundColor = UIColor.WhiteColor()
if you drop collection view opacity to 0 the whole collection view will be invisible. In your case you want to show collection view cell only so collection view cell's background view should be UIColor.clear either collection view background. Programmatically like this
self.collectionView.backgroundView?.backgroundColor = UIColor.clear
self.collectionView.backgroundColor = UIColor.clear
In my case i need to show chat log like this so i used that code
my example case
In the UICollectionView set the background color to clearcolor in the attribute inspector.
Dropping UICollectionView's Opacity to 0 from attribute inspector will make it transperent.
P.S:
Bad practice, but will work.
I'm setting the backgroundView of a tableView like this:
self.tableView.backgroundView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:#"background"]];
It works but gets placed on top of the tableview's activity indicator and hides it when the tableview is pulled down for refresh. I've tried setting a breakpoint on the point it's added and confirmed that indeed it goes on top of the activity indicator subviews array. Is there any way to fix this?
Thanks in advance.
I suggest that is better to place UIImageView below your UITableView and set:
_yourTableView.backgroundColor = [UIColor clearColor];
Currently, I am using a UITableViewController. I'm setting a background image on the table view. I have a custom view which contains a segmented control and a search bar that I am setting as the table view header. I'm styling its background to be transparent so that you can see the background image behind it.
Here's what it looks like so far:
However, I would like it to look like this, where the white background color of the table view spans the full height:
How can I achieve this effect?
UIImageView *views = [[UIImageView alloc] initWithFrame:viewFrame];
views.image = [UIImage new];
self.tableView.tableHeaderView = views;
Wouldn't these steps solve your problem ?
remove the tableview background image;
set the tableview background color to white;
add the background image to the table view header instead.
Why is the background of my table view grey when there are no rows? I can't see where this is set in storyboard
Even setting the background to white explicitly I still get a grey background
Using the defaults for background also results in this grey background:
this might be due to two reason
a) you haven't set data source and delegate and your main view background color is gray
b) cell background color is gray, set that to clear color
Please add this code viewdidload or viewwillappear method
table.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
For me it looks like it is a problem of the UITableViewCells, you should set them to
self.backgroundColor = [UIColor whiteColor]; // or clearColor
then also set the UITableView itself inside the controller to backgroundColor white or grey.
Also the snippet of #Rohitsuvagiya can help to let dissappear the separators if there is no additional UITableViewCell.
Please add line your code in viewdidload or viewillappear
table.backgroundColor=[UIColor clearColor];
I know the UItableView have a property named:backgroundView, but this view not scroll with the table, I want add a background after the table, and can scroll .
How can I do that.
Thanks very much.
You have to set the background image via backgroundColor property of UITableView:
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"background.png"]];