【代码笔记】iOS-UITextField设置placeholder颜色
2016-06-28 09:07
567 查看
一,效果图。
二,工程图。
三,代码。
RootViewController.h
RootViewController.m
二,工程图。
三,代码。
RootViewController.h
#import <UIKit/UIKit.h> @interface RootViewController : UIViewController <UITextFieldDelegate> @end
RootViewController.m
#import "RootViewController.h" @interface RootViewController () @end @implementation RootViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. UITextField *textField=[[UITextField alloc]initWithFrame:CGRectMake(50, 100, 200, 50)]; //UITextField设置placeholder颜色 UIColor *color = [UIColor redColor]; textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"密码" attributes:@{NSForegroundColorAttributeName: color}]; textField.delegate=self; [self.view addSubview:textField]; }
相关文章推荐
- 【代码笔记】iOS-UITextField设置placeholder颜色
- request.getContextPath() 下有红线 生成不成功
- NGUI 制作简易背包UI
- 巧用UIResponder进行事件传递
- vuejs与服务器通信
- vuejs件同一个挂载点上切换组
- LeetCode 347. Top K Frequent Elements
- 数控软件Grbl使用系列(2):烧写到Arduino UNO
- 获取UILabel宽度的方法
- UISlider
- UIScrollView UICollectionView 无法响应touch事件
- UIKit,UIView
- 动态绑定事件插件—livequery
- 1.大道至简的数据处理工具(Power Query)
- requirejs的简单使用
- ui2
- UI
- 128. Longest Consecutive Sequence
- UIImage图片处理(更改颜色,修改透明度,缩小,合并图片)
- EasyUI 之 dataGrid前台状态值转换