改变UITextField的Placeholder颜色

通过 attributedPlaceholder 属性来改变

if([textField respondsToSelector:@selector(setAttributedPlaceholder:)]
{
UIColor*color =[UIColor blackColor];
textField.attributedPlaceholder =[[NSAttributedString alloc] initWithString:placeholderText attributes:@{NSForegroundColorAttributeName: color}];
}else{
NSLog(@"Cannot set placeholder text‘s color, because deployment target is earlier than iOS 6.0");
// TODO: Add fall-back code to set placeholder color.
}

原文:http://www.cnblogs.com/kingW/p/3730206.html

时间: 2024-08-29 19:57:44

改变UITextField的Placeholder颜色的相关文章

【代码笔记】UITextField设置placeholder颜色

一,效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> @interface RootViewController : UIViewController <UITextFieldDelegate> @end RootViewController.m #import "RootViewController.h" @interface RootViewController () @end @i

IOS 开发更改UITextField的Placeholder颜色

UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(100, 200, 200, 40)];    UIColor *color = [UIColor redColor]; textField.backgroundColor = [UIColor yellowColor]; textField.attributedPlaceholder = [[NSAttributedString alloc] initW

iOS UITextField设置placeholder颜色

设置UITextField的placeholder颜色 UIColor *color = [UIColor blackColor]; textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"密码" attributes:@{NSForegroundColorAttributeName: color}]; iOS UITextField设置placeholder颜色

UITextField自定义placeHolder颜色并保持placeHolder居中

思路: 1.自定义UITextField的子类 2.重写drawPlaceholderInRect方法改变placeHolder颜色 3.重写placeholderRectForBounds方法保持placeHolder文字居中 代码如下: @interface CustomPlaceHolderTextField : UITextField @end @implementation CustomPlaceHolderTextField - (void)drawPlaceholderInRect

UITextField的placeholder颜色的修改

使用属性 @property(nonatomic,copy) NSAttributedString *attributedPlaceholder; // 文字属性 NSMutableDictionary *attrs = [NSMutableDictionary dictionary]; attrs[NSForegroundColorAttributeName] = [UIColor grayColor]; // NSAttributedString : 带有属性的文字(富文本技术) NSAtt

iOS 改变UITextField中光标颜色

http://blog.csdn.net/rubycrow/article/details/22411805 方法1: [objc] view plaincopyprint? [[UITextField appearance] setTintColor:[UIColor blackColor]]; 这种方法将影响所有TextField. 方法2: [objc] view plaincopyprint? textField.tintColor = [UIColor redColor]; 如果在In

IOS_改变UITextField placeHolder颜色、字体

IOS_改变UITextField placeHolder颜色.字体 我们有时需要定制化UITextField对象的风格,可以添加许多不同的重写方法,来改变文本字段的显示行为.这些方法都会返回一个CGRect结构,制定了文本字段每个部件的边界范围,甚至修改placeHolder颜色,字体. – textRectForBounds:     //重写来重置文字区域 – drawTextInRect:        //改变绘文字属性.重写时调用super可以按默认图形属性绘制,若自己完全重写绘制函

[转]改变UITextField placeHolder颜色、字体

本文转载至 http://m.blog.csdn.net/blog/a394318511/8025170 我们有时需要定制化UITextField对象的风格,可以添加许多不同的重写方法,来改变文本字段的显示行为.这些方法都会返回一个CGRect结构,制定了文本字段每个部件的边界范围,甚至修改placeHolder颜色,字体. – textRectForBounds:     //重写来重置文字区域 – drawTextInRect:        //改变绘文字属性.重写时调用super可以按默

(转) 改变UITextField placeHolder颜色、字体 、输入光标位置等

我们有时需要定制化UITextField对象的风格,可以添加许多不同的重写方法,来改变文本字段的显示行为.这些方法都会返回一个CGRect结构,制定了文本字段每个部件的边界范围,甚至修改placeHolder颜色,字体. – textRectForBounds:     //重写来重置文字区域 – drawTextInRect:        //改变绘文字属性.重写时调用super可以按默认图形属性绘制,若自己完全重写绘制函数,就不用调用super了. – placeholderRectFor