Latest 0.0.3
Homepage https://github.com/xtzPioneer/TXCTextField
License MIT
Platforms ios 8.0, requires ARC
Authors
  • 只需简单操作即可监听TextField输入,监听第一响应事件,改变描述颜色以及对齐方式等功能。

    cocoapods集成

  • pod ‘TXCTextField’, ‘~> 0.0.3’

    代码片段

    /*TextField改变*/
    typedef void (^TXTextFieldDidChange)(TXCTextField * textField);
    /*第一响应*/
    typedef BOOL (^TXFirstResponder)(TXCTextField * textField);
    /*描述Alignment*/
    typedef NS_ENUM(NSInteger,TXPlaceholderAlignment){
    TXPlaceholderAlignmentLeft   = 0,//居左
    TXPlaceholderAlignmentCenter = 1,//居中
    TXPlaceholderAlignmentRight  = 2,//居右
    };
    @interface TXCTextField : UITextField
    /*描述字体*/
    @property (nonatomic,strong)UIFont  * placeholderFont;
    /*描述颜色*/
    @property (nonatomic,strong)UIColor * placeholderColor;
    /*光标颜色*/
    @property (nonatomic,strong)UIColor * cursorColor;
    /*描述间距*/
    @property (nonatomic,assign)CGFloat placeholderSpacing;
    /*左侧文本填充宽度*/
    @property (nonatomic,assign)CGFloat textFieldLeftPaddingWidth;
    /*描述对齐方式*/
    @property (nonatomic,assign)TXPlaceholderAlignment placeholderAlignment;
    /*TextField改变*/
    @property (nonatomic,copy)TXTextFieldDidChange  textFieldDidChange;
    /*第一响应*/
    @property (nonatomic,copy)TXFirstResponder firstResponderHandler;

使用方法

  • 导入头文件 直接使用TXCTextField…即可
  • (void)viewDidLoad {
    [super viewDidLoad];
    TXCTextField textField=[[TXCTextField alloc]init];
    textField.frame=CGRectMake(40, 64, self.view.frame.size.width-40
    2, 30);
    textField.layer.borderColor=[UIColor grayColor].CGColor;
    textField.layer.borderWidth=1;
    textField.layer.cornerRadius=15;
    textField.layer.masksToBounds=YES;
    [email protected]"描述";
    //光标颜色
    textField.cursorColor=[UIColor redColor];
    //描述字体
    textField.placeholderFont=[UIFont systemFontOfSize:13];
    //描述对齐方式
    textField.placeholderAlignment=TXPlaceholderAlignmentCenter;
    //左侧文本填充宽度
    textField.textFieldLeftPaddingWidth=10;
    //TextField改变
    textField.textFieldDidChange = ^(TXCTextField textField) {
    NSLog(@"text:%@",textField.text);
    };
    //第一响应
    textField.firstResponderHandler = ^BOOL(TXCTextField
    textField) {
    NSLog(@"第一响应");
    return YES;
    };
    [self.view addSubview:textField];

    // Do any additional setup after loading the view, typically from a nib.
    }

    
    ### 版本更新说明
    #### 0.0.3 版本更新内容
  • 优化项目结构,解决描述字体不能垂直居中问题。

0.0.2 版本更新内容

  • 重构项目结构
  • 新增光标起始位置
  • 系统高度保持一致

Latest podspec

{
    "name": "TXCTextField",
    "version": "0.0.3",
    "summary": "u53eau9700u7b80u5355u64cdu4f5cu5373u53efu76d1u542cTextFieldu8f93u5165,u76d1u542cu7b2cu4e00u76f8u5e94u4e8bu4ef6,u6539u53d8u63cfu8ff0u989cu8272u4ee5u53cau5bf9u9f50u65b9u5f0fu7b49u529fu80fdu3002",
    "description": "u53eau9700u7b80u5355u64cdu4f5cu5373u53efu76d1u542cTextFieldu8f93u5165,u76d1u542cu7b2cu4e00u76f8u5e94u4e8bu4ef6,u6539u53d8u63cfu8ff0u989cu8272u4ee5u53cau5bf9u9f50u65b9u5f0fu7b49u529fu80fdu3002u91cdu6784u9879u76eeu7ed3u6784u3001u65b0u589eu5149u6807u8d77u59cbu4f4du7f6eu3001u548cu7cfbu7edfu9ad8u5ea6u4fddu6301u4e00u81f4u7b49u3002",
    "homepage": "https://github.com/xtzPioneer/TXCTextField",
    "license": "MIT",
    "authors": {
        "zhangxiong": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/xtzPioneer/TXCTextField.git",
        "tag": "0.0.3"
    },
    "source_files": "TXCTextField/**/*.{h,m}",
    "requires_arc": true
}

Pin It on Pinterest

Share This