UI细节属性

UITextField不常用属性

2016-02-22  本文已影响47人  FengxinLi

1设置placeholder字体颜色和字体大小

第一种方法

UITextField  field=[[UITextField alloc]initWithFrame:CGRectMake(0, 0, 300, 300)];

[field setValue:[UIColor yellowColor] forKeyPath:@"_placeholderLabel.textColor"];

[field setValue:[UIFont boldSystemFontOfSize:16] forKeyPath:@"_placeholderLabel.font"];

第二种方法

field.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"请输入账号" attributes:@{NSForegroundColorAttributeName: [UIColor orangeColor],NSFontAttributeName:[UIFont boldSystemFontOfSize:34]}];

2inputAccessoryView属性使用, 

UITextFields和UITextView有一个inputAccessoryView的属性,当你想在键盘上展示一个自定义的view时,你就可以设置该属性。你设置的view就会自动和键盘keyboard一起显示了。

需要注意的是,你所自定义的view既不应该处在其他的视图层里,也不应该成为其他视图的子视图。其实也就是说,你所自定义的view只需要赋给属性inputAccessoryView就可以了,不要再做其他多余的操作。

上一篇 下一篇

猜你喜欢

热点阅读