用UITextView模拟UITextField的placeHolder 效果: 源码: // // ViewController.m // TextView // // Created by YouXianMing on 14/12/18. // Copyright (c) 2014年 YouXianMing. All rights reserved. // #import "ViewController.h" static NSString *placeHolderStr = @&…
由于最近有用到输入框,刚开始考虑的是UITextField,因为它在没有输入的时候可以有提示的Placeholder更能,很人性化,但UITextField只能单行输入,不能跳行,对于一些强迫症的亲来说,很别捏!所以我就想用UITextView,并找出Placeholder的类似方法.我的思路是使用2个UITextView来模拟出UITextField的PlaceHolder效果,一个背景为透明的TextView放在最上面,另一个责作为PlaceHolder的TextView放在最底层.它们之间…
本文转载至 http://blog.csdn.net/hengshujiyi/article/details/9086093- (void)initFeedBackViews { //设置页面的背景颜色 UIColor *ViewBgColor = [UIColor colorWithRed:(247.0f/255.0f)green:(247.0f/255.0f) blue:(247.0f/255.0f) alpha:1.0f]; self.view.backgroundColor = View…
更改UITextField的placeholder文字颜色的5种方法 想要达到的目标是:一个页面上有多个UITextField,当用户聚焦某textField时,该文本框的placeholder的文字会灰色变为白色,当文本框失去焦点时,placeholder颜色从白色再变回灰色. 1.放置UILabel 最简单最笨的方法是在每个textField里放一个UILabel来充当placeholder,当该textField聚焦时,让placeholder的文字会灰色变为白色,失焦后从白色再变回灰色.…
- (void)viewDidLoad { [super viewDidLoad]; self.title=@"修改UITextField的placeholder字体颜色"; UITextField *textTF=[[UITextField alloc]initWithFrame:CGRectMake(20,130,300,30)]; textTF.placeholder=@"修改UITextField的placeholder字体颜色"; //    // 一种方…
IOS中的UITextView和UITextField都是文本输入控件并都能够调用系统键盘.本次特酷把介绍UITextView和UITextField的区别.简单来说,UITextView和UITextField最大的区别是:UITextView支持多行输入,而UITextField只能单行输入.实际上,UITextView继承自UIScrollView,UITextField继承自UIView[UIControl].在使用上我们完全可以把UITextView看作是UITextField的加强版…
设置UITextField的placeholder颜色 UIColor *color = [UIColor blackColor]; textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"密码" attributes:@{NSForegroundColorAttributeName: color}];…
第一种方法: [textfeild setValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor"]; 第二种方法: @interface LBTextField : UITextField @end @implementation LBTextField - (void)drawPlaceholderInRect:(CGRect)rect{ [[UIColor orangeColor] setFill]; […
//创建UITextField对象 UITextField * tf=[[UITextField alloc]init];    //设置Placeholder颜色 [text setAttributedPlaceholder:[[NSAttributedString alloc]initWithString:CustomLocalizedString(@"UserName", nil) attributes:@{NSForegroundColorAttributeName:[UICo…
转自:http://blog.csdn.net/mazy_ma/article/details/51775670 有时,UITextField自带的Placeholder的颜色太浅或者不满足需求,所以需要修改,而UITextField没有直接的属性去修改Placeholder的颜色,所以只能通过其他间接方式去修改. 例如:系统默认的Placeholder颜色太浅 需要加深颜色,或者改变颜色 方法一:通过attributedPlaceholder属性修改Placeholder颜色 CGFloat…