首页 > 其他 > 详细

UITextview 垂直居中

时间:2015-08-31 23:02:21      阅读:175      评论:0      收藏:0      [点我收藏+]


 UITextView* content = (UITextView*) [cell viewWithTag:104];

[content addObserver:self forKeyPath:@"contentSize" options:(NSKeyValueObservingOptionNew) context:NULL];

#pragma mark - KVO

-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context

{

    UITextView *tv = object;

    // Center vertical alignment

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

    

} 

UITextview 垂直居中

原文:http://www.cnblogs.com/li-baibo/p/4774230.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!