开发者

How to Center Text in UITableView.tableHeaderView?

I am adding a UILabel to the tableHeaderView but for some reason it is left aligned.

self.messageLabel = [[UILabel alloc] initWithFrame:CGRectZero]; 
[self.messageLabel setText:@"Nothing to display!"];

[self.tableView setTableHeaderView:self.messageLabel];
[self.tab开发者_StackOverflow社区leView.tableHeaderView setBackgroundColor:[UIColor blueColor]];
[self.tableView.tableHeaderView setFrame:CGRectMake(320/2, 480/2, 100, 20)];
[self.messageLabel setCenter:self.tableView.tableHeaderView.center];


[label setTextAlignment:UITextAlignmentCenter];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜