开发者

How to align a UITableView's text?

In my app I have a UITableView and I want to change the text's alignme开发者_运维百科nt to center (not only from the sides like this

     cell.textAlignment = UITextAlignmentCenter;

but from up and down, as well).

Can you help me? thanks in advance!


Could you please clarify the question? If you use UITableViewCellStyleDefault and increase cell height something like

- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  return 100;
}

then the label will be vertically centered without any effort on your part.

Also, cell.textAlignment = … is deprecated in favor of cell.textLabel.textAlignment = ….


This will do it, assuming you are using textLabel for your text.

cell.textLabel.textAlignment = UITextAlignmentCenter

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜