Customizing Section indexes in UITableView in iphone application

前端 未结 5 1596
忘掉有多难
忘掉有多难 2020-12-03 17:56
  • Does any one have tried to customize default section index displayed in UITableView.
  • I want to modify the appearance of UITableView SectionIndex.
  • Is
相关标签:
5条回答
  • 2020-12-03 18:17
    tableView.tintColor = UIColor.redColor();
    

    will do it for you

    0 讨论(0)
  • 2020-12-03 18:21

    Swift version:

    tableView.sectionIndexBackgroundColor = UIColor.clearColor() //iOS7+
    tableView.sectionIndexTrackingBackgroundColor = UIColor.clearColor() //iOS6+
    tableView.sectionIndexColor = UIColor.redColor() //iOS6+
    

    To customize the index view height (UITableViewStylePlain style only):

    tableView.sectionIndexMinimumDisplayRowCount = 15
    
    0 讨论(0)
  • 2020-12-03 18:26

    Actually there is not official Apple available to do that. And Apple may reject you app if you do that. If you just wants to customize indexBar then below library may help you.

    You can use custom library CollectionIndexTools by Swift(iOS 8+), which you can customize.

    https://github.com/ReverseScale/CollectionIndexTools

    Here's sample snippet for CollectionIndexTools

    lazy var collectionViewIndex: CollectionViewIndex = {
            let collectionViewIndex = CollectionViewIndex()
            collectionViewIndex.indexTitles = ["c", "v", "t", "m", "n", "w", "e", "r", "t", "y", "u", "i", "o", "p", "h", "d", "c", "b", "q"]
            collectionViewIndex.addTarget(self, action: #selector(FakeCollectionViewController.selectedIndexDidChange(_:)), for: .valueChanged)
            collectionViewIndex.translatesAutoresizingMaskIntoConstraints = false
            return collectionViewIndex
        }()
    
    0 讨论(0)
  • 2020-12-03 18:33

    https://github.com/Hyabusa/CMIndexBar

    Use this plugin from Hyabusa. Simple replacment for UITableView Index that allows setting of colors

    CMIndexBar *indexBar = [[CMIndexBar alloc] initWithFrame:CGRectMake(self.view.frame.size.width-35, 10.0, 28.0, self.view.frame.size.height-20)];
    [indexBar setIndexes:[NSMutableArray arrayWithObjects:@"A",@"B",@"C",@"D",@"E",@"F",@"G", nil]];
    [self.view addSubview:indexBar];
    [indexBar release];
    

    Delegate

    - (void)indexSelectionDidChange:(CMIndexBar *)IndexBar:(int)index:(NSString*)title;
    
    0 讨论(0)
  • 2020-12-03 18:37

    It doesn't look like standard index view is customizable.

    In my application I just created custom index view instead of standard one. Basically all you need to do here is track touch position in that view and scroll UITableView accordingly. You may also need to add some visual effects - change view's background color on touch and highlight current section title.

    0 讨论(0)
提交回复
热议问题