美文网首页
SYPlaceHolderTextView带占位符的UIText

SYPlaceHolderTextView带占位符的UIText

作者: 番薯大佬 | 来源:发表于2017-10-17 14:19 被阅读1次

SYPlaceHolderTextView继承自UITextView,且带有占位符和block回调的自定义textview。

效果图效果图

代码示例

// 导入头文件
#import "SYPlaceHolderTextView.h"
// 实例化
SYPlaceHolderTextView *textview = [[SYPlaceHolderTextView alloc] initWithFrame:CGRectMake(10.0, 10.0, (self.view.frame.size.width - 10.0 * 2), 80.0) view:self.view];
// 属性设置
textview.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.3];
textview.layer.cornerRadius = 5.0;
textview.layer.masksToBounds = YES;

// 限制字符长度
textview.limitNumber = 20;

// 回车结束编辑
textview.isEndReturn = YES;
// 占位符设置
textview.placeHolderText = @"请输入你想要输入的任何信息。注意字数限制!";
textview.placeHolderFont = [UIFont systemFontOfSize:12.0];
textview.placeHolderColor = [UIColor redColor];
// block回调
[textview textViewStart:^(UITextView *textview) {
    NSLog(@"start text %@", textview.text);
} changeTextInRange:^(UITextView *textview, NSRange range, NSString *text) {
    NSLog(@"change text %@", textview.text);
} changeNotification:^(UITextView *textview) {
    NSLog(@"change text %@", textview.text);
} end:^(UITextView *textview) {
    NSLog(@"end text %@", textview.text);
}];

相关文章

  • SYPlaceHolderTextView带占位符的UIText

    SYPlaceHolderTextView继承自UITextView,且带有占位符和block回调的自定义text...

  • 莹莹

    占位符占位符占位符占位符占位符占位符占位符占位符占位符占位符占位符占位符占位符占位符占位符占位符占位符占位符占位符...

  • 莹莹

    占位符占位符占位符占位符占位符占位符占位符占位符占位符占位符占位符占位符占位符占位符占位符占位符占位符占位符占位符...

  • 语言元素及列表学习

    语言元素 占位符 %d是整数的占位符,%f是小数的占位符,%%表示百分号(因为百分号代表了占位符,所以带占位符的字...

  • 三、@PathVariable

    3.1@PathVariable 映射 URL 绑定的占位符 带占位符的 **URL **是 **Spring3....

  • 及时止损哪有那么容易

    占位符占位符占位符占位符占位符占位符占位符占位符占位符占位符 晚上清理微博时,发现了我以前发的微博 心情如同标题 ...

  • SpringBoot的参数注解

    1、@PathVariable:接收请求路径中占位符的值 带占位符的 URL 是 Spring3.0 新增的功能,...

  • golang fmt

    占位符 普通占位符 布尔占位符 整数占位符 指针 其它标记

  • 占位符

    占位符占位符

  • UITextView(占位字符,限制字数)

    请关注,防止你用了,我改了,有问题连个商量的人都找不到... 自定义带占位符的TextView 设置占位符方式千奇...

网友评论

      本文标题:SYPlaceHolderTextView带占位符的UIText

      本文链接:https://www.haomeiwen.com/subject/warduxtx.html