sjo*_*ors 2 objective-c uitableview tableheader
我有一个UITableView分区,并且想要在标签上设置一个标签(不在tableview中).
我试着设置有标签[label setText:@"name"];
的
(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
Run Code Online (Sandbox Code Playgroud)
但那没用.其他人有想法如何做到这一点?
试试这个
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 30, 60)];
headerView.backgroundColor = [UIColor clearColor];
UILabel *label = [[UILabel alloc] initWithFrame: CGRectMake(0,0, 50, 50)];
label.backgroundColor = [UIColor yellowColor];
label.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;
[headerView addSubview:label];
return headerView;
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
12665 次 |
最近记录: |