Setting image to tableview background - ios

I have added an imageview on top of tableview. I need to set it to the back of tableview without setting it as a background on tableview.
sendSubviewToBack:bgView also does not work. Can someone help?

try like this ,
if objects are in xib ,then take imageview infront of tableview in xib,
(or)
if you are adding in programatically then add imageview before adding the tableview
(or)
table.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:#""]];
(or)
[table bringSubviewToFront:yourImageview];

Try this
self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"table_bg_image.png"]];

Not getting what exactly you want .
One another way from XIB , just simply add it into the xib behind your table View , and set your tableView's background colour as clearcolor, So you'll be able to see the image behind your tableview.

Related

tableView background image hides activity indicator

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];

setting Transparency to the UITableView

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];

Restore default UITableViewCell backgroundView

In short, I need to restore the default backgroundView for a UITableViewStyleGrouped cell.
cell.backgroundView = ??;
The long story:
I have a grouped tableview with some cells. For every cell the user needs to select some value or do some input. After that he can proceed to the next ViewController by touching a "next" button.
Anyway, to indicate to the user that he missed something, I display a nice red border around the cell with the wrong/missing user input. I do that by setting the backgroudView of the cell with a custom image like this:
cell.backgroundView = myErrorIndicatingImageView;
The cell now looks like this (screenshot, ignore the stars and label)
So far so good, this works like a charm. But after the user corrects the input I want to remove my red border background image and just show the original background again. The original background looks like this (screenshot):
And this seems to be a problem.
I tried several things
// try by setting the background to nil
cell.backgroundView = nil;
this removes the background completely and I'm lost with a cell without background.
// try it with addSubview and later remove the subview again
[cell.backgroundView addSubview:myErrorIndicatingImageView];
this does nothing. The myErrorIndicatingImageView is not visible. Even a [cell.backgroundView bringSubviewToFront:myErrorIndicatingImageView] does not help.
Right now the only solution I have is to create a new UITableViewCell for every single call to cellForRowAtIndexPath. This works but is just bad code and ignores completely the technique to reuse cells.
There must be a simpler solution...something like
cell.backgroundView = [self.tableView getDefaultBackgroundView];
what about trying this:
cell.backgroundView = [[UIView alloc] initWithFrame:cell.backgroundView.frame];
Or you can make the background view as a UIImageView and set 2 images in problem and fixed
Assuming you are doing this with a custom table cell class, save the original backgroundView in some ivar, then apply the new background. When you want to reset the background, set the backgroundView back to the original, saved background view.

Get rid of line above UITableView

I have a UITableView (which happens to have a UISearchBar) and can't seem to figure out how to get rid of the white/gray border above it. I need to have seamless black between the UISearchBar and the black above it.
I have tried hiding the UISearchBar to see if that had anything to do with it, but the line still appeared.
Any ideas?
In my case it helped to set:
searchBar.clipsToBounds = YES;
You have to customise the UISearchBar background to match according to your requirements.,take a look at this tutorial.
You should try this, by which you can set the color of cell borders and if you want to change the color of a particular cell's border put it in condition as: if (indexPath.row == yourcell):
tableView.separatorColor = [UIColor blackColor];
Also the above method you have to put in CellForRowAtIndexPath method of table view datasource.
Please notify if it works..
This had to do with the pullToRefresh view I was using (using SensibleTableView) - it had some code in drawRect to draw the line.

How to scroll UITableView background view when scroll the table

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"]];

Resources