iphone - Textview Center Text Alignment IOS 7 -
-(void)observevalueforkeypath:(nsstring *)keypath ofobject:(id)object change:(nsdictionary *)change context:(void *)context { nslog(@"hello"); 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}; }
i calling in viewdidload
[mytextview1 addobserver:self forkeypath:@"contentsize" options:(nskeyvalueobservingoptionnew) context:null];
textview.textalignment = nstextalignmentcenter;
Comments
Post a Comment