【发布时间】:2013-06-06 03:18:40
【问题描述】:
我想在UItextView 中垂直居中对齐文本。
我正在使用以下代码
UITextView *tv = object;
CGFloat topCorrect = ([tv bounds].size.height - [tv contentSize].height * [tv zoomScale])/2.0;
topCorrect = ( topCorrect < 0.0 ? 0.0 : topCorrect );
tv.contentOffset = (CGPoint){.x = 0, .y = -topCorrect}
;
不知何故,这在 iOS 5 中不起作用,因为返回的 contentSize 与我在 iOS6 中得到的不同。
知道为什么 iOS 5 和 iOS 6 中相同 textView 的 contentSize 不同吗?
【问题讨论】:
标签: ios uitextview