views:

346

answers:

2

I'm trying to place a UILabel directly in the middle of a UITableViewCell vertically. Essentially I'm doing something such as:

float yPos = self.contentView.center.y;

I then assign yPos to my UILabel and add it as a subview of self.contentView within my UITableView subclass.

This still doesn't appear to be smack in the middle of the cell.

What am I missing?

+1  A: 

Are you subtracting (height of UILabel / 2) from yPos?

clee
I'm not... I wish there was a cheat sheet for this stuff. how should the math look?
randombits
+1  A: 
float yPos = self.contentView.frame.size.height - (label.frame.size.height / 2)
jamone
That's not quite correct - you're putting it at exactly the bottom there. It should be:float yPos = self.contentView.center.y - (label.frame.size.height / 2) instead.
clee