Cat Share, must boutique
Original articles, welcome reprint. Reprint Please specify: Sanayu's Blog
Address: http://blog.csdn.net/u013357243
Effect:
A good way to encapsulate:
Cat encapsulation of a small method, simple to share out, convenient for later code copy if there is a better opinion can tell me, object-oriented is a big project, but I walk 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