码迷,mamicode.com
首页 > 其他好文 > 详细

UItextField的用法

时间:2015-12-19 01:26:59      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:

修改placehoder的颜色:

[ self.loginnameText setValue:[UIColor colorWithRed:184.f/255 green:214.f/255 blue:225.f/255 alpha:1] forKeyPath:@"_placeholderLabel.textColor"];

    [ self.passwordText setValue:[UIColor colorWithRed:184.f/255 green:214.f/255 blue:225.f/255 alpha:1] forKeyPath:@"_placeholderLabel.textColor"];

改变键盘类型:

self.loginnameText.returnKeyType = UIReturnKeyNext;

    self.passwordText.returnKeyType = UIReturnKeyGo;

给左右两边添加View:

_clearRightButton = [UIButton buttonWithType:UIButtonTypeCustom];

    [_clearRightButton setFrame:CGRectMake(0, 0, 20, 20)];

    [_clearRightButton setBackgroundImage:[UIImage imageNamed:@"cha"] forState:UIControlStateNormal];

    [_clearRightButton addTarget:self action:@selector(clearLoginName) forControlEvents:UIControlEventTouchUpInside];

    

    _clearRightButtonR = [UIButton buttonWithType:UIButtonTypeCustom];

    [_clearRightButtonR setFrame:CGRectMake(0, 0, 20, 20)];

    [_clearRightButtonR setBackgroundImage:[UIImage imageNamed:@"cha"] forState:UIControlStateNormal];

    [_clearRightButtonR addTarget:self action:@selector(clearPassWord) forControlEvents:UIControlEventTouchUpInside];

    

    self.loginnameText.rightView =_clearRightButton;

    self.loginnameText.rightViewMode=UITextFieldViewModeWhileEditing;

    self.passwordText.rightView =_clearRightButtonR;

    self.passwordText.rightViewMode=UITextFieldViewModeWhileEditing;

UItextField的用法

标签:

原文地址:http://www.cnblogs.com/wll-winner/p/5058530.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!