添加索引 两种方式,ios新手总结篇

来源:互联网 发布:东方快车杀人事件知乎 编辑:程序博客网 时间:2024/04/30 11:56

在设置搜索ABCDEFG...的时候 可以在tableview上设置属性

self.ui_tableView.sectionIndexColor = RGB_MD(120, 209, 97);  //改变abcd。。。的颜色

        self.ui_tableView.sectionIndexBackgroundColor = [ColorManager clearColor]; //  改变abcdefg的背景颜色

        self.ui_tableView.sectionIndexTrackingBackgroundColor = [ColorManager clearColor];



//自定义添加索引 在代理事件中这样写

-(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView

{

    NSMutableArray * title = [[NSMutableArrayalloc]init];

    [title addObject:UITableViewIndexSearch];

    for (int i='A'; i<='Z'; i++)

    {

        [title addObject:[NSStringstringWithFormat:@"%c",(char)i]];

    }

    [title addObject:@"#"];

    [title addObject:@"#"];

    [title addObject:@"#"];

    [title addObject:@"#"];

    [title addObject:@"#"];

    [title addObject:@"#"];

    [title addObject:@"#"];

    return title;

}

//索引对应关系正常 不用重写



1 0
原创粉丝点击