# STTextView **Repository Path**: yanglishuan/STTextView ## Basic Information - **Project Name**: STTextView - **Description**: 自定义UITextView,STTextView可以设置placeHolder和字符个数,达到字符限制不能再输入;另外还添加了字符变化的block回调,方便开发者使用。 - **Primary Language**: Objective-C - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 11 - **Forks**: 0 - **Created**: 2014-12-17 - **Last Updated**: 2025-09-04 ## Categories & Tags **Categories**: ios-modules **Tags**: None ## README #STTextView STTextView可以设置placeHolder和字符个数,达到字符限制不能再输入;另外还添加了字符变化的block回调,方便开发者使用。 ![image](http://git.oschina.net/yanglishuan/STTextView/raw/master/ScreenShots/screenshot1.png) ![image](http://git.oschina.net/yanglishuan/STTextView/raw/master/ScreenShots/screenshot2.png) ``` #define MAXLENGTH 100 STTextView *textView = [[STTextView alloc] initWithFrame:CGRectMake(20, 84, self.view.bounds.size.width - 40, 120)]; textView.placeholder = [NSString stringWithFormat:@"写点什么吧,最多%@个字", @(MAXLENGTH)]; textView.maxLength = MAXLENGTH; textView.font = [UIFont systemFontOfSize:15]; [textView setTextDidChangeBlock:^(UITextView *textView) { _countLabel.text = [NSString stringWithFormat:@"还可以写%@个字", @(MAXLENGTH - textView.text.length)]; }]; textView.layer.borderColor = [UIColor lightGrayColor].CGColor; textView.layer.borderWidth = 1.0; textView.layer.opacity = .7; [self.view addSubview:textView]; ```