2 Star 5 Fork 0

stlwtr / STTextView

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 1.06 KB
一键复制 编辑 原始数据 按行查看 历史
stlwtr 提交于 2015-03-02 22:19 . fit error

#STTextView

STTextView可以设置placeHolder和字符个数,达到字符限制不能再输入;另外还添加了字符变化的block回调,方便开发者使用。

image image

#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];
    
Objective-C
1
https://gitee.com/yanglishuan/STTextView.git
git@gitee.com:yanglishuan/STTextView.git
yanglishuan
STTextView
STTextView
master

搜索帮助