设置TextField左右视图
-(id)initWithFrame:(CGRect)frame drawingLeft:(UIImageView *)icon drawingRight:(UIButton *)bu{
self = [super initWithFrame:frame];
if(self) {
self.leftView = icon;
self.leftViewMode = UITextFieldViewModeAlways;
self.rightView= bu;
self.rightViewMode=UITextFieldViewModeAlways;
}
returnself;
}
-(CGRect)leftViewRectForBounds:(CGRect)bounds{
CGRect iconRect = [super leftViewRectForBounds:bounds];
iconRect.origin.x += 5;
// 右偏10returniconRect;
}
-(CGRect)rightViewRectForBounds:(CGRect)bounds{
CGRect burect=[super rightViewRectForBounds:bounds];
burect.origin.x +=-10;returnburect;
}
修改textFieldplaceholder字体颜色和大小
textField.placeholder = @"username is in here!";
[textFieldsetValue:[UIColor redColor]forKeyPath:@"_placeholderLabel.textColor"]; [textFieldsetValue:[UIFont boldSystemFontOfSize:16]forKeyPath:@"_placeholderLabel.font"];