我正在将UITextField定制为更高,并且具有与默认值不同的边框颜色和阴影:
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField {
textField.layer.shadowOpacity = 0.f;
textField.layer.cornerRadius = 6.f;
textField.layer.borderColor = [[UIColor colorWithRed:196/255.0 green:111/255.0 blue:3/255.0 alpha:1] CGColor];
textField.layer.borderWidth = 1.f;
return YES;
}
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
textField.layer.shadowColor = [[UIColor blackColor] CGColor];
textField.layer.shadowOpacity = .2f;
textField.layer.shadowOffset = CGSizeMake(0,3);
textField.layer.shadowRadius = 3.f;
textField.clipsToBounds = NO;
textField.layer.cornerRadius = 6.0f;
textField.layer.borderColor = [[UIColor colorWithRed:196/255.0 green:111/255.0 blue:3/255.0 alpha:1] CGColor];
textField.layer.borderWidth = 3.f;
return YES;
}
然而,似乎有些东西在左下角的“未聚焦”状态下搞砸了边框的渲染: