垂直对齐文本的核心? [英] Vertical align with Core Text?

查看:351
本文介绍了垂直对齐文本的核心?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何改变一个CTFramesetter框架文本的垂直对齐方式?我希望我的文字在中间而不是被在最常见的。我使用的核心文本框架。还有就是段落的设置来改变水平aligment而不是垂直的。

How do I change the vertical alignment of the text in a CTFramesetter frame? I want my text to be in the middle instead of being at the top. I am using Core Text framework. There is a setting of the paragraph to change horizontal aligment but not vertical.

推荐答案

终于找到它了...

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));

这篇关于垂直对齐文本的核心?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆