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 sa开发者_如何学Pythonid 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?
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]];
}
}
}
if yo want to make any change in indexbar you should use CAlayer.
Set UITableViewCell background color using a CALayer
as of iOS 6 you can use sectionIndexColor to set the font color of the vertical alphabetical index bar. you can also set the background color around the vertical alphabetical index bar when the users is dragging with their finger with the sectionIndexTrackingBackgroundColor. Be sure to check to make sure the device is at 6 or higher if you are also targeting iOS 5 devices. -rrh
//iOS 6 devices only
[[self tableView] setSectionIndexColor:[UIColor whiteColor]];
//if targeting devices prior to iOS6 prevent a crash by verifying device OS version
NSArray *versionCompatibility = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."];
NSInteger OSVersion = [[versionCompatibility objectAtIndex:0] intValue];
if (OSVersion >= 6) {
[[self tableView] setSectionIndexColor:[UIColor whiteColor]];
}
There is no native way to customize your index bar. Try out this custom index bar instead. It's quite easy to use and customize:
https://github.com/debris/AIMTableViewIndexBar
精彩评论