1
居中文本垂直我有以下代碼繪製文本垂直居中(和水平)在一個矩形:在矩形
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];
然而,我的文字繪製幾個像素太高。我的計算是否正確?