[英]iOS How to set a gradient color to UITextField cursor
您可以要求设计者提供一张pix图片,然后按如下所示进行操作:
UIColor *collor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"one"]];
self.textfield.tintColor = collor;
要更改UITextField光标颜色,您已将其设置为UIColor
类型的“色调颜色”。
textField.tintColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"gradient"]];
使用UITextField外观代理对应用程序中的所有文本字段执行以下操作:
[[UITextField appearance] setTintColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"gradient"]]];
奖励:如果您需要为UIView
设置渐变颜色:
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = view.bounds;
gradient.colors = @[(id)[UIColor whiteColor].CGColor, (id)[UIColor blackColor].CGColor];
[view.layer insertSublayer:gradient atIndex:0];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.