1. 程式人生 > >textView 自動換行, 可以文字內容動態移動

textView 自動換行, 可以文字內容動態移動

-(void)textViewDidChange:(UITextView *)textView{
   
//部落格園-FlyElephant static CGFloat maxHeight = 95;
   
CGRect frame = textView.frame;
   
   
   
CGSize constraintSize = CGSizeMake(frame.size.width, MAXFLOAT);
   
CGSize size = [textView sizeThatFits:constraintSize];
   
if (size.height<=maxHeight) {
        size.
height=maxHeight;
    }
    textView.
scrollEnabled = NO;    // 不允許滾動
    textView.
frame = CGRectMake(frame.origin.x, frame.origin.y, frame.size.width, size.height);