I have the following code to draw text centered vertically (and horizontally) in a rect:
CGSize size=[self.buttonText sizeWithFont:font];
CGRect textFrame=CGRectMake(self.bounds.size.width/2-size.width/2, self.bounds.size.height/2-size.height/2, size.width, size.height);
[self.buttonText drawInRect:textFrame withFont:font];
However, my text is drawn a few pixels too high. Am I doing my calculations correctly?
Your code looks fine. Try giving a background color for the same rect to see / debug what is happening.