搜尋

首頁  >  問答  >  主體

ios - tableview 中的 点击右侧索引时,颜色改变的方法?

如图所示, 当点击字母H时, 改变他的颜色, 我没找到这个方法, 请教一下怎么处理

阿神阿神2889 天前285

全部回覆(1)我來回復

  • PHPz

    PHPz2017-04-17 17:42:36

    • (UITableViewCell )tableView:(UITableView )tv cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    for(UIView *view in [tv subviews])
    {

    if([[[view class] description] isEqualToString:@"UITableViewIndex"])
    {
    
      [view setBackgroundColor:[UIColor whiteColor]];
      [view setFont:[UIFont systemFontOfSize:14]];
    }

    }

    //rest of cellForRow handling...

    }
    系統沒有提供方法 我們可以遍歷subview找到它在返回cell代理裡修改
    Ant-Bang互助社區(Q群 426981364)為你回答

    回覆
    0
  • 取消回覆