QYTextView 1.0.6

QYTextView 1.0.6

Joeyoung 维护。



  • joeyoung

QYTextView

使用方法

和正常使用 UITextView 一样。在原有系统类的基础上扩展了两个属性,占位文字和限制字数。

  • 无需担心设置属性的先后顺序,赋值即生效;
  • 占位文本会根据字体大小,自动调整居中显示;
  • 输入内容超出 UITextView 高度时,限制字数文本将悬浮在原始位置,不受滚动影响;
  • 如果不给这些属性赋值,则不会有任何效果。
/**
The text of the placeholder text.
*/
@property (nonatomic, copy) NSString *placeholder;
/**
The color of the placeholder text. Default is lightGray.
*/
@property (nonatomic, strong) UIColor *placeholderColor;
/**
The font of the placeholder text. Default is 12-point system font.
*/
@property (nonatomic, strong) UIFont *placeholderFont;
/**
The limit of the text. Default is hidden.
when you use 'xx.imitNumber = ' the limitNumber text is show.
*/
@property (nonatomic, assign) NSUInteger limitNumber;
/**
The color of the limitNumber text. Default is lightGray.
*/
@property (nonatomic, strong) UIColor *limitColor;
/**
The font of the limitNumber text. Default is 12-point system font.
*/
@property (nonatomic, strong) UIFont *limitFont;

示例

CGRect rect = CGRectMake(0, 40, self.view.bounds.size.width, 240);
QYTextView *textView = [[QYTextView alloc] initWithFrame:rect];
textView.returnKeyType = UIReturnKeyDone;
textView.backgroundColor = [UIColor cyanColor];
textView.font = [UIFont systemFontOfSize:16];
textView.textColor = [UIColor blackColor];
textView.placeholder = @"请输入您的内容。。。";
textView.placeholderFont = [UIFont systemFontOfSize:14];
textView.placeholderColor = [UIColor grayColor];
textView.limitNumber = 100;
textView.limitFont = [UIFont systemFontOfSize:14];
[self.view addSubview:textView];

效果图

要求

安装

QYTextView 可通过 CocoaPods 获取。要安装它,只需将以下行添加到您的 Podfile 中

pod 'QYTextView'

作者

Joeyoung, [email protected]

许可证

QYTextView 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。