我试图将 UILabel 直接垂直放置在 UITableViewCell 的中间。本质上我正在做一些事情,例如:
float yPos = self.contentView.center.y;
然后,我将 yPos 分配给我的 UILabel,并将其添加为 UITableView 子类中 self.contentView 的 subview 。
这似乎仍然没有正好位于单元格的中间。
我错过了什么?
最佳答案
float yPos = (CGRectGetHeight(self.contentView.frame) - CGRectGetHeight(label.frame)) / 2;
关于iphone - 将 UILabel 置于高度动态的 UITableViewCell 中的最佳方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2246551/