Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView Index bar Customization

I'd call my skills to be almost "basic", I understand most of what i read and see when it comes to objective-c but this is a bit outta the grasp of my comprehension.

i have a tableView with a transparent background along with transparent cells, unfortunately the person i am developing the app for insists on having a background show thru that is primarily grey. My issue is the index bar to the right. I have read that text color, background color and the likes are off limits when it comes to customization. Has anyone created their own index bar and attached it to the tableView's scrolling methods?

like i said i am at a loss when it comes as to where to even begin. All i need i belive is a point in the right direction. do i need to create a small UIView and play with the touch events?

like image 221
Jason Bugs Adams Avatar asked Feb 28 '11 08:02

Jason Bugs Adams


People also ask

What class does UITableView inherit from?

The tableview is the instance of the UITableView class, which inherits the UIScrollView class.

What is true about Uiviewtable section?

UITableView manages the basic appearance of the table, but your app provides the cells ( UITableViewCell objects) that display the actual content. The standard cell configurations display a simple combination of text and images, but you can define custom cells that display any content you want.

How does a Tableview work?

A table view displays a single column of vertically scrolling content, divided into rows and sections. Each row of a table displays a single piece of information related to your app. Sections let you group related rows together. For example, the Contacts app uses a table to display the names of the user's contacts.


2 Answers

Just do it like that:

if ([[self tableView] respondsToSelector:@selector(setSectionIndexColor:)])
{
    // In iOS 6 there is a own method available to set the index color
    [[self tableView] setSectionIndexColor:[UIColor whiteColor]];
}
else
{
    // Use this hack in previous iOS releases
    for(UIView *view in [self.tableView subviews])
    {
        if([view respondsToSelector:@selector(setIndexColor:)])
        {
            [view performSelector:@selector(setIndexColor:) withObject:[UIColor whiteColor]];
        }
    }
}
like image 154
miho Avatar answered Nov 07 '22 03:11

miho


if yo want to make any change in indexbar you should use CAlayer.

Set UITableViewCell background color using a CALayer

like image 39
GameLoading Avatar answered Nov 07 '22 02:11

GameLoading