{

    UITextView *ownTextView;// 自我介绍

    UILabel *ownLabel;

    UILabel *numLabel;

}

 

先添加UITextViewDelegate

 ownTextView = [[UITextView alloc]initWithFrame:CGRectMake(20, 50, ScreenWidth-40, 100)];

        ownTextView.backgroundColor = [UIColor whiteColor];

        ownTextView.font = NORMALFONT;

        ownTextView.textColor = [UIColor lightGrayColor];

        ownTextView.textAlignment = NSTextAlignmentLeft;

        ownTextView.editable = YES;

        ownTextView.delegate = self;

        

       ownLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, ownTextView.width, ownTextView.hash)];

        ownLabel.text = @"【示例】本人以从事此行业10年,熟练掌握各种专业技能,性格热情开朗,待人友好,为人诚实谦虚。";

        ownLabel.textColor = [UIColor lightGrayColor];

        ownLabel.textAlignment = NSTextAlignmentLeft;

        ownLabel.font = NORMALFONT;

        ownLabel.numberOfLines = 3;

        [ownLabel sizeToFit];

        [ownTextView addSubview:ownLabel];

 

 numLabel = [[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth-100, ownTextView.bottom+10, 80, 20)];

        numLabel.text = @"0/200字";

        numLabel.textAlignment = NSTextAlignmentRight;

        numLabel.textColor = [UIColor grayColor];

        numLabel.font = NORMALFONT;

        [headView addSubview:numLabel];

数字可以放外面 也可以放到TextView里

#pragma mark ------textViewDelegate

//开始编辑

-(void)textViewDidBeginEditing:(UITextView *)textView{

  ownLabel.text = @"";

    numLabel.text = [NSString stringWithFormat:@"%lu/200字",(unsigned long)textView.text.length];

 

}

//结束编辑

-(void)textViewDidEndEditing:(UITextView *)textView{

  numLabel.text = [NSString stringWithFormat:@"%lu/200字",(unsigned long)textView.text.length]; 

}

 

// 文本发生改变

- (void)textViewDidChange:(UITextView *)textView{

    numLabel.text = [NSString stringWithFormat:@"%lu/200字",(unsigned long)textView.text.length];

    if (textView.text.length >= 200) {

        textView.text = [textView.text substringToIndex:200];

        numLabel.text = @"200/200";

    }

}