2015-05-06 46 views
0

我遇到了UITableViewCell中垂直對齊的問題。垂直對齊UITableViewCell中的UITextlabel

我正在使用右側細節 UITableViewCell中的detailTextLabel包含多行文本。 通過設置行數爲零,我設法讓detailTextLabel顯示所有文本。這會導致(左)文本標籤對齊左上角而不是UITableViewCell的中心。

有沒有辦法使用其中detailTextLabel包含多行(在這種情況下2),並使主文本標籤垂直居中的TableViewCell?

Current UITableViewCell alignment

+2

如果您的使用案例不同,您應該創建自己的原型單元格 –

+0

您是否嘗試設置標籤的垂直對齊? cell.textLabel.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter –

+0

@DejanSkledar我不相信'contentVerticalAlignment'是UITextLabel的屬性? – Berendschot

回答

-2

您應該使用UIControlContentVerticalAlignmentCenter,使兩個標籤的高度相等。

但我寧願創建自己的自定義單元格。

+0

'UIControlContentVerticalAlignmentCenter'是'UITextField'的屬性,而不是'UILabel' – Berendschot