iOS UITextField设置placeholder颜色

设置UITextField的placeholder颜色

UIColor *color = [UIColor blackColor];

textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"密码" attributes:@{NSForegroundColorAttributeName: color}];

iOS UITextField设置placeholder颜色

时间: 2024-10-11 10:17:35

iOS 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

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

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

UITextView模拟UITextField 设置Placeholder属性 --董鑫

由于最近有用到输入框,刚开始考虑的是UITextField,因为它在没有输入的时候可以有提示的Placeholder更能,很人性化,但UITextField只能单行输入,不能跳行,对于一些强迫症的亲来说,很别捏!所以我就想用UITextView,并找出Placeholder的类似方法.我的思路是使用2个UITextView来模拟出UITextField的PlaceHolder效果,一个背景为透明的TextView放在最上面,另一个责作为PlaceHolder的TextView放在最底层.它们之间

iOS学习-UITextField设置placeholder的颜色

UITextField *text = [[UITextField alloc] initWithFrame:CGRectMake(50, 200, 200, 40)]; text.borderStyle = UITextBorderStyleRoundedRect; NSMutableAttributedString * attributedStr = [[NSMutableAttributedString alloc]initWithString:@"密码"]; [attribut

iOS UITextField 设置下底边

@interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(30, 100, 160, 30)]; textField.text = @"设置textField下边框"; CALayer *b

改变UITextField的Placeholder颜色

通过 attributedPlaceholder 属性来改变 if([textField respondsToSelector:@selector(setAttributedPlaceholder:)] { UIColor*color =[UIColor blackColor]; textField.attributedPlaceholder =[[NSAttributedString alloc] initWithString:placeholderText attributes:@{NSFo

iOS UISearchBar 设置光标颜色和取消按钮颜色

这个问题其实可以取个巧路,大家都知道设置SearchBar的tintcolor的方法 searchBar.tintColor = [UIColor blueColor]; [[UIBarButtonItem appearanceWhenContainedIn:[UISearchBar class], nil] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys: [UIColor whiteColor], UITe

iOS UITextField 设置内边距

http://blog.csdn.net/erica_sadun/article/details/9088181 1.inherit UITextField Class. ? [cpp]?view plaincopy .h?? //?? //??TextField.h?? //??TTShow?? //?? //??Created?by?twb?on?13-9-10.?? //??Copyright?(c)?2013年?twb.?All?rights?reserved.?? //?? ?? #i