永发信息网

如何把TableView的section header 居中

答案:3  悬赏:50  手机版
解决时间 2021-02-15 23:06
  • 提问者网友:佞臣
  • 2021-02-15 12:24
如何把TableView的section header 居中
最佳答案
  • 五星知识达人网友:野味小生
  • 2021-02-15 12:46
这个需要设置table的头的位置,设置一下它的frame;
具体参考实例如下:
(UIView *)tableView:(UITableView *)tableView
viewForHeaderInSection:(NSInteger)section {
return 15;
}

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0,0,320,15)];
label.textAlignment = UITextAlignmentCenter
label.text = @"Text Should Be Centered";
全部回答
  • 1楼网友:不想翻身的咸鱼
  • 2021-02-15 13:54
-(uiview *) tableview:(uitableview *)tableview viewforheaderinsection:(nsinteger)section { _tableheader = [[uiview alloc] initwithframe:cgrectmake(0, 0, 320, 100)]; _tableheader.backgroundcolor = [uicolor redcolor]; _tableheade
  • 2楼网友:怀裏藏嬌
  • 2021-02-15 13:21
-(UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { _tableHeader = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 100)]; _tableHeader.backgroundColor = [UIColor redColor]; _tableHeader.alpha = 0; [UIView animateWithDuration:1.0 animations:^{ [_tableHeader setAlpha:1.0f]; }]; return _tableHeader;}
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯