我从 Interface Builder(IB) 创建了一个 UITextField。因为我想要自定义样式,所以我在 IB 中选择了 None 样式。在 viewDidLoad 上,我为它分配了以下样式:
txtEmail.layer.cornerRadius = 8.0;
txtEmail.layer.borderColor = [UIColor colorWithWhite:199.0/255.0 alpha:1].CGColor;
txtEmail.layer.borderWidth = 1.0;
txtEmail.layer.shadowColor = [UIColor blackColor].CGColor;
txtEmail.layer.shadowOpacity = 0.17;
txtEmail.layer.shadowOffset = CGSizeMake(-0.9,0.9);
txtEmail.layer.shadowRadius = 1.1;
// This is to provide a left padding for None styled textfields
UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 5, 20)];
txtEmail.leftView = paddingView;
txtEmail.leftViewMode = UITextFieldViewModeAlways;
现在我的文本字段的样式变得完美,但我的占位符文本(在 IB 中提供)也继承了该阴影。我怎样才能摆脱它?