美文网首页
uitableview sectionTextTitle 滚动显

uitableview sectionTextTitle 滚动显

作者: LV大树 | 来源:发表于2018-03-03 12:05 被阅读10次

uitableview sectionTextTitle 滚动显示时可以做点什么。可以参考这个方法

代码来自:CityPickerViewController
https://github.com/guoshimeihua/CityPickerViewController

  • (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index {
    [self showIndexTitle:title];

    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    [self dissmissIndexTitle];
    });

    return [_indexArray[index] integerValue];
    }

  • (void)showIndexTitle:(NSString *)indexTitle {
    self.view.userInteractionEnabled = NO;
    self.indexTitleLabel.text = indexTitle;
    [self.view addSubview:self.indexTitleLabel];
    }

  • (void)dissmissIndexTitle {
    self.view.userInteractionEnabled = YES;
    [self.indexTitleLabel removeFromSuperview];
    }

  • (void)labelPrepare {
    self.indexTitleLabel.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.4];
    self.indexTitleLabel.center = self.view.center;
    self.indexTitleLabel.bounds = CGRectMake(0, 0, 120, 120);
    self.indexTitleLabel.font = [UIFont boldSystemFontOfSize:80];
    self.indexTitleLabel.textAlignment = NSTextAlignmentCenter;
    self.indexTitleLabel.textColor = [UIColor whiteColor];
    }

相关文章

网友评论

      本文标题:uitableview sectionTextTitle 滚动显

      本文链接:https://www.haomeiwen.com/subject/waetfftx.html