JJMaterialTextField
基于 Objective C 的基于 Material Design 的 UITextfield 子类
示例项目
要运行示例项目,请首先克隆仓库,然后从示例目录运行 pod install
要求
- ARC
- iOS 7
安装
JJMaterialTextField 通过 CocoaPods 提供使用。要安装它,请简单地将以下行添加到您的 Podfile 中
pod "JJMaterialTextField"
使用方法
导入
#import "JJMaterialTextField.h"
初始化文本字段并进行配置
JJMaterialTextfield *textField =[[JJMaterialTextfield alloc] initWithFrame:CGRectMake(40, 120, self.view.frame.size.width-80, 34)];
textField.textColor=[UIColor whiteColor];
textField.enableMaterialPlaceHolder:YES;
textField.errorColor=[UIColor colorWithRed:0.910 green:0.329 blue:0.271 alpha:1.000]; // FLAT RED COLOR
textField.lineColor=[UIColor colorWithRed:0.482 green:0.800 blue:1.000 alpha:1.000];
textField.tintColor=[UIColor colorWithRed:0.482 green:0.800 blue:1.000 alpha:1.000];
textField.placeholder=@"Username";
[self.view addSubview:textField];
使用占位符属性
textField.placeholderAttributes = @{NSFontAttributeName : [UIFont systemFontOfSize:20],
NSForegroundColorAttributeName : [[UIColor grayColor] colorWithAlphaComponent:.8]};
作者
Juanjo Guevara, [email protected]
许可协议
JJMaterialTextField 在 MIT 许可协议下可用。更多信息请查看 LICENSE 文件。