由于最近有用到输入框,刚开始考虑的是UITextField,因为它在没有输入的时候可以有提示的Placeholder更能,很人性化,但UITextField只能单行输入,不能跳行,对于一些强迫症的亲来说,很别捏!所以我就想用UITextView,并找出Placeholder的类似方法.我的思路是使用2个UITextView来模拟出UITextField的PlaceHolder效果,一个背景为透明的TextView放在最上面,另一个责作为PlaceHolder的TextView放在最底层.它们之间…
用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对象 UITextField * tf=[[UITextField alloc]init];    //设置Placeholder颜色 [text setAttributedPlaceholder:[[NSAttributedString alloc]initWithString:CustomLocalizedString(@"UserName", nil) attributes:@{NSForegroundColorAttributeName:[UICo…
设置UITextField的placeholder颜色 UIColor *color = [UIColor blackColor]; textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"密码" attributes:@{NSForegroundColorAttributeName: color}];…
只要把原来的placeholder属性改为attributedPlaceholder属性即可 具体代码如下图:…
本文转载至 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 *text = [[UITextField alloc] initWithFrame:CGRectMake(, , , )]; text.borderStyle = UITextBorderStyleRoundedRect; NSMutableAttributedString * attributedStr = [[NSMutableAttributedString alloc]initWithString:@"密码"]; [attributedStr addA…
实现方式:css div:empty:before{ content: attr(placeholder); color:#bbb;}div:focus:before{ content:none; }…
p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica; color: #ff2608 } [_textField setValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor"];…
<textarea></textarea>标签的placeholder属性不生效问题   1.在用到<textarea></textarea>标签时,设置placeholder属性提示不生效问题解决办法: 2.代码里写<textarea  rows="10" name="List" class="box" placeholder="请输入提示文案"></text…