UITextview 垂直居中


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

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

#pragma mark - KVOspa

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

{orm

    UITextView *tv = object;server

    // Center vertical alignmentblog

    CGFloat topCorrect = ([tv bounds].size.height - [tv contentSize].height * [tv zoomScale])/2.0;it

    topCorrect = ( topCorrect < 0.0 ? 0.0 : topCorrect );io

    tv.contentOffset = (CGPoint){.x = 0, .y = -topCorrect};import

    

} 

相關文章
相關標籤/搜索