MXInputTextFieldView 1.1.6

MXInputTextFieldView 1.1.6

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Jun 2017

Maintained by HuangMingxing.



  • By
  • HuangMingxing

高度自定义UITextField

功能

  • 支持添加图标
  • 支持设置placeholder字体、颜色
  • 支持标题动画
  • 支持输入出错时,添加摇头动画
  • 支持设置键盘类型、return键类型
  • 支持给键盘上方添加确定按钮
  • 支持事件回调

效果示例

  • 功能列表
    功能列表

  • 效果图
    效果

  • 摇头动画
    效果

使用说明

添加文件

* 将MXInputTextFieldClass文件夹内容添加到项目中
* 在文件中 #import "MXInputTextFieldView.h"

代码示例

/*ViewController.m*/
#import "MXInputTextFieldView.h"

@interface ViewController ()
@property (strong, nonatomic) MXInputTextFieldView *tf;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.tf = [[MXInputTextFieldView alloc]initWithFrame:CGRectMake((self.view.frame.size.width-200)/2.0, 50, 200, 45)];
    //设置左icon
    self.tf.leftImageName = @"phone";
    //设置placeholder文本
    self.tf.placeholder = @"请输入手机号码";
    //设置placeholder颜色
    self.tf.placeholderColor = [UIColor yellowColor];
    //设置placeholder字体
    self.tf.placeholderFont = [UIFont systemFontOfSize:13];
    //设置title,若为空,则没有动画
    self.tf.titleText = @"手机号";
    //设置title字体
    self.tf.titleFont = [UIFont systemFontOfSize:13];
    //设置最大字数
    self.tf.maxLimit = 8;
    //设置return键类型
    self.tf.returnKeyType = UIReturnKeyNext;
    //设置点击return键事件
    self.tf.returnHandler = ^{
        NSLog(@"点击了return按钮");
    };
    //给键盘上方添加确定按钮
    self.tf.hasSureButtonView = YES;
    
    /*
    设置更多属性,参考MXInputTextFieldView.h;
    具体用法参考Demo~
    */
    
    [self.view addSubview:_tf];
}

- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    //隐藏键盘
    self.tf.activity = NO;
}

@end