How to set a background image or view to a section of a grouped UITableView? I know how to set the background of the cells and how to set a fixed background for the table view, but what i need is a background for a section.
I think your only option here is to cut your background up into the shape of the individual cells and set it as the cell backgrounds. There no method that allows you to return a view for the background of an entire section.
Related
I am trying to put a transparent table view over a map. First, I set backgroundcolor as clearColor and it didn't work. Then I set alpha on the table view as 0.5 then it is transparent but text in labels also transparent. I want to see through the map but text in label should stand out. I reset the alpha on the label but it is still not effective. How can I do this in iOS7?
Thanks!
You need to set the background color of each table cell as clearColor. Set this in your cellForRowAtIndexPath method.
Well, I have a uitableview with 4 cells with content, so there are 4 cells displayed and other 4 cells displayed without content to fit the screen. I want all the cells in my uitableview to have a background image (the same for all). When I change the background of the cell on cellForRowAtIndexPath method only the 4 cells with content get the background image and the other 4 without content are still white. Is there any way I can set the background to all the cells an not only to the cells with content?
You may be able to add the additional four cells as blank cells to your table view. This way, they still look exactly like one of your other cells. An alternative may be to make the cells larger which would make you need to use less "filler" cells.
Hope this helps!
increase the number of rows in the section....
lets say u want 100 cells to get the background image... then the cellforRowAtIndex path will be called for 100 cells and hence will set the background..
Hope it works
Let me Know
I'm trying to achieve an effect wherein as a tableview is scrolling, the currently visible cells will animate according to where they are positioned on the screen. I'm somewhat new to IOS dev, so let me try to break it down:
Tableview loads with custom cells User begins scrolling While the
table is in motion, the visible cells have a UIView in which I would
like to perform an animation that corresponds directly to the cell's
current Y position on the screen.
Cells will ONLY animate when they
are visible
Cell animation directly corresponds to table motion, i.e.
whenever the table view scrolls, the cells are animating; once the
table stops, the animations pause
One solution I have thought of is to update drawRect every single frame when the tableview is moving. Depending on the graphic operations, this could be horrible performance wise. Is there a way to grab the current table position every time it changes? Would I be better suited to use Core Animation?
This might be helpful if you want to achieve something like below:
https://github.com/mrugrajsinh/AnimatedTableViewCellDemo
Make your view controllers the delegate of the UITableView, and use all the methods of scrollview Delegate also. There you have many controls for start scrolling and end scrolling, and within thpse controls you could check for uitableview cell positioning.
You have to become delegate to this: https://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UITableViewDelegate_Protocol/Reference/Reference.html
and this is the method to override and animate your cells:
– tableView:willDisplayCell:forRowAtIndexPath:
I want to customize my NSTableView. My overall requirements are like this:
Each row will have one image and some text; images and text could be different.
Some cells might not have an image.
Row height is dependent upon some external factor.
A cell shouldn't draw the background, it should show the NSTableView background.
So far I am able to draw transparent cells with some text. I Googled and found out I need to customize each cell. Now I have this question: should I maintain two columns or should one column be okay, having one image on the left hand side and text adjacent to that?
I also understand that I need to override two methods:
- (void) drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
So for each cell, I need to draw/construct the cell -- can anyone guide me? Am I going in the right direction? Can I achieve a transparent background with dynamic height with the above approach?
Each row will have one image and some text,
So, two columns—one with an image cell, the other with a text field cell.
images and text could be different,
I should hope so.
Some cell might not have the Image,
Not a problem.
Row height is depend upon some external factor,
Be the table view's delegate, and it will ask you what the row's height should be.
Cell shouldn't draw the background,
It won't unless you set it to do so.
it should overall it should show the NSTableView background,
The table view will draw its own background anyway, which you can set in IB's Inspector. If you wanted the table view to not draw a background, you would set its background colors to the clear color.
You don't need a custom cell for any of this.
How could I change the background of each row of a NSTableView?
The documentation will tell you.
If you want to set the background color differently for specific rows, columns, or row-column intersections, be the table view's delegate and respond to tableView:willDisplayCell:forRow: by setting the background color of the cell.