标签:line ble rac ber src 代码 app oct ram
猫猫分享,必须精品
原创文章。欢迎转载。转载请注明:翟乃玉的博客
地址:http://blog.csdn.net/u013357243
猫猫封装的一个小方法,简单共享出来,方便以后代码copy假设有更好的意见能够告诉我。面向对象是个大的project,然而咱走在路上。
/**
* 给UITextField设置右側的图片
*
* @param textField UITextField
* @param imageName 图片名称
*/
-(void)setRightViewWithTextField:(UITextField *)textField imageName:(NSString *)imageName{
UIImageView *rightView = [[UIImageView alloc]init];
rightView.image = [UIImage imageNamed:imageName];
rightView.size = CGSizeMake(40, 40);
rightView.contentMode = UIViewContentModeCenter;
textField.rightView = rightView;
textField.rightViewMode = UITextFieldViewModeAlways;
}
调用:
- (void)viewDidLoad {
[super viewDidLoad];
[self setRightViewWithTextField:self.userNameTextField imageName:@"zc01"];
[self setRightViewWithTextField:self.passwordTextField imageName:@"zc02"];
}
猫猫学iOS之UITextField右边设置图片,以及UITextField全解
标签:line ble rac ber src 代码 app oct ram
原文地址:http://www.cnblogs.com/mfmdaoyou/p/7298457.html