Is there a way to fix the background image of a UITableView - iphone

I have set the background of my UITable with a custom image.
self.tableView.backgroundColor = [UIColor clearColor];
self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"background.png"]];
The problem I'm having is the background image is scrolling and doesn't look good at the top and bottom of the screen where you see the image being joined.
Is there a way to fix the position of the background image and just have the table scroll over the top of it?

Insert a UIImageView behind the UITableView. Set the UIImageView's image to background.png. Use [UIColor clearColor] as the table's background.

You need to put a UIImageView beneath your table view, set the table view's background color to clear (or in IB, set the opacity property of its background at 0). Then construct your CELL views to have clear areas that your background image can be seen through. You can do that programmatically or in IB (it's easier to visualize in IB, but the code to hook it all together is a bit tricky).

Related

Different colors for grouped tableView and tableViewCell backgrounds

How can I set different colors for GROUPED UITableView inside background vs. background, which is outside my table? That is the part which is visible when tableView is smaller than the screen or scrolled beyond limits of table.
UPDATE: that sample image is generated by my current code! I DO NOT NEED TIPS HOW TO MAKE IT !!! Please read the question before you (try to) answer. Would really appreciate this, but thanx anyway.
File AboutViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
self.tableView.backgroundView = [[CustomView alloc]
initWithFrame:self.tableView.bounds]; // VISIBLE
self.tableView.backgroundColor = [UIColor redColor]; // NOT VISIBLE
}
In the sample image (generated by my current code) the background view contains sample gradient from yellow to green, each cell "bubble" background is texture, each label has own background - all this just to demonstrate what I could define. As you can see, background gradient is partially visible through each cell and remains static when you scroll the table.
What I want to do: I want DIFFERENT tableView background for GROUPED UITableView.
For plain UITableView style I have defined a custom background for each cell, but it doesn't seem to work with GROUPED tableView. This only sets the cell background inside the cell "bubble". How to define the cell area outside that cell "bubble"?
For this you can use the image as backgroundimage.
But I think you are using the grouped table,so
you need to go with the tableview background color
and set that to image color.
Like
winTableView.backgroundColor=[UIColor colorWithPatternImage:#"bg.png"];
Or you can even go with the Gradient layer,inserting that in you view.
Hope this will help you.
Get the image of different color as you want to show the background of your table view.
For this u set cell.backgroundColor =[UIColor redColor]; its work
and for background u tale image or set color
For cell color or view you can also use these.
Try to have different color for different cells by your logic.
cell.backgroundColor=[UIColor clearColor];
//cell.selectionStyle=UITableViewCellSelectionStyleNone;
cell.accessoryType=UITableViewCellAccessoryNone;
UIView *backroundSelecView=[[[UIView alloc]init]autorelease];
backroundSelecView.backgroundColor=[UIColor colorWithRed:203.0/255.0f green:218.0/255.0f blue:140.0/255.0f alpha:.80];
cell.selectedBackgroundView=backroundSelecView;
cell.backgroundView=[[[UIImageView alloc]initWithImage:[UIImage imageNamed:#"table-grid#2x.png"]]autorelease];

UITapGestureRecognizer on transparent view

I have a tree with views where the highest level view is transparent and contains either an image or a label (with a transparent background).
When attaching a UITapGestureRecognizer to this view, I only get notifications on the views which contain images.Also, if I leave the view empty, then I get events only when the background color is different than [UIColor clearColor].
I have done a dump and the entire view tree has userInteractionEnable = YES.
How can I get the UITapGesturerRecognizer to work on the view with a transparent background?
Solved
Problem was not what I thought. The transparent views were in a scroll view and during initialization they were outside of the view's visible area. Those within the visible area work ok.
Wild guesses here, but if you include a 1x1 pixel image in the view, would that view then qualify for gestures?
Another equally wild guess would be to add a transparent image to the view and try that.
Try giving the view a nearly-transparent background color, like [UIColor colorWithWhite:0 alpha:0.01].
Try setting the background color to whatever except the clearColor and setting the alpha property to 0.0;
myView.backgroundColor = [UIColor blackColor];
myView.alpha = 0.0;

Layering UIViews so that bottom most layer can be seen

I have a UIView to which i add a background image. Then to that view i add a scroll view. To the scroll view i add some UIButtons.
I would like to be able to set the scroll view to be transparent (still being able to see the UIButtons) so that i can see the background image underneath it, so that it shows between the buttons.
I have tried setting the scrollview background to [UIColor clearColor] but this doesnt work.
Thanks.
In addition to setting the backgroundColor to [UIColor clearColor], you also have to set
scrollView.opaque = NO;
Change the UIScrollView.alpha level to 0.0f

One background image must be displayed on the whole

I am new to iphone development.When i tried to displayed a background image for my table view ,image appears for every cells.I want display single image thats fits the screen and not displayed in every cell.Please help me out.Thanks.
Make your table view a subview of a UIView (let's call it parentView). You can then make the table view's background clear to show the UIView positioned underneath. You then set that UIView to contain an image view:
self.tableView.backgroundColor = [UIColor clearColor];
[self.parentView addSubview:myImageView];

Black corners on UITableView Group Style

I have a problem where my UITableView (group style) has a black "tip" above it's rounded corner.
I'm setting up the background of the tableview like so:
[meetingTableView setBackgroundColor:[[UIColor alloc] initWithPatternImage:[[UIImage alloc] initWithContentsOfFile:#"background.png"]]];
And my table view ends up looking like this:
black pointy edge on rounded corner http://papernapkin.org/pastebin/resource/images/imageEntryId/6487
Any ideas how I can get rid of those black points?
I have got the same problem.
When I set clear color by xib, I have the back corner
The solution is to set it by code !
(The same problem with interface builder exist for webviews)
Try this in your controller's viewDidLoad method:
meetingTableView.backgroundColor = [UIColor clearColor];
You'll get Black corners on UITableView Group Style if you set background color to clear color in XIB.
Instead try this code for removing Black corners on UITableView Group Style
tableViewObject.backgroundColor=[UIColor clearColor];
Just in case you weren't already aware, there's another neat technique you can use to make customized backgrounds for UITableViews:
Not quite as simple as setting the background as you're doing, but it gives you a lot more flexibility and can scale to any table size.
Maybe if you put yourTableViewOutlet.backgroundView=nil;
To avoid the black corners you have to make sure that the UITableViewCells are not opaque. It looks like you're using custom styles table cells and the default value for opaque is YES. Either go to Interface Builder and uncheck the opaque checkbox if the table cell was set up in a XIB file. Or use the setOpaque:NO setter to change value.
Because the table cell view still has a rectangular frame even with the rounded corners the cell view and not the actual table view is causing those black corners.
My guess is that it's related to something that you're doing in your custom table view cells. You might want to experiment with setting the cell background color to [UIColor clearColor].
I think you should set the background color of your table as clearColor and initialsie your view with the background image.
Then it will definitely not show the black corners. But also don't forget to set the background color of your cell as white color
The up-voted answer above (set the tableView's background to [UIColor clearColor]) may not work for you if you are like me and never use the UITableViewController, instead putting a UITableView inside a UIViewController.
In this case it's not the tableView that needs to have a clear background, but the view that holds the tableview.
This is not intuitive, but it works for me. In interface builder you can just set the parent view's background color to clear color, or you could do the same in code in viewDidLoad with:
self.view.backgroundColor = [UIColor clearColor];
I'm guessing the reason for the black corners is something about the internal graphics optimization, and setting the background clear fixes it.