核心文本 - 垂直对齐(多行)

时间:2013-01-09 08:18:44

标签: objective-c cocoa core-text

在此question后,我了解了如何垂直对齐单行文本:

CGRect boundingBox = CTFontGetBoundingBox(font);

//Get the position on the y axis
float midHeight = self.frame.size.height / 2;
midHeight -= boundingBox.size.height / 2;

CGPathAddRect(path, NULL, CGRectMake(0, midHeight, self.frame.size.width, boundingBox.size.height));

但此代码仅适用于单行上下文。当帧生成多行字符串(具有软线或硬线断开)时,该代码不起作用。

0 个答案:

没有答案
相关问题