Cat Share, must boutique
Original article. Welcome reprint. Reprint Please specify: Sanayu's Blog
Address: http://blog.csdn.net/u013357243
Effect:
A good way to encapsulate:
A small method of cat encapsulation, simple to share out, convenient later code copy assumes that there is better advice to tell me. Object-oriented is a big project, but we're on the road.
/** * 给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(4040); rightView.contentMode = UIViewContentModeCenter; textField.rightView = rightView; textField.rightViewMode = UITextFieldViewModeAlways;}
Call:
- (void)viewDidLoad { [super viewDidLoad]; [self setRightViewWithTextField:self.userNameTextField imageName:@"zc01"]; [self setRightViewWithTextField:self.passwordTextField imageName:@"zc02"];}
Cat learns iOS Uitextfield right set picture, and Uitextfield full solution