Today just learned Uitextfield control, feel in the inside set placeholder is very good, give the user prompt information, so just want to placeholder font and color can change it?
Here are some simple implementations of the small series.
There are two main ways of doing this:
Method 1: Use Rich Text
@property (Weak, nonatomic) Iboutlet Uitextfield *textfield;
Nsdictionary *dic = @{nsforegroundcolorattributename:[uicolor Magentacolor], Nsfontattributename:[uifont SYSTEMFONTOFSIZE:15]};
Self.textField.attributedPlaceholder = [[Nsattributedstring alloc] initwithstring:@ "Welcome back" attributes:dic];
Self.textField.tintColor = [Uicolor Cyancolor];
Method 2:KVC
Self.textField.placeholder = @ "Welcome back!";
[Self.textfield setvalue:[uicolor Magentacolor] forkeypath:@ "_placeholderlabel.textcolor"]
[Self.textfield Setvalue:[uifont systemfontofsize:15] forkeypath:@ "_placeholderlabel.font"];
Self.textField.tintColor = [Uicolor Greencolor];
KVC functions A lot, you can also achieve simple summation of the array
Nsarray *dataarray = @[@ "1", @ "2", @ "3", @ "4", @ "5"];
NSNumber *sum = [DataArray valueforkeypath:@ "@sum. IntegerValue"];
NSLog (@ "%@", sum);
Set the color and font of the Uitextfield placeholder