//创建UITextField对象
UITextField * tf=[[UITextField alloc]init];
 
 //设置Placeholder颜色

[text setAttributedPlaceholder:[[NSAttributedString alloc]initWithString:CustomLocalizedString(@"UserName", nil) attributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}]];

//设置UITextField的文字颜色
tf.textColor=[UIColor redColor];
 
//设置UITextField的文本框背景颜色
tf.backgroundColor=[UIColor grayColor];
 
//设置UITextField的边框的风格
tf.borderStyle=UITextBorderStyleRoundedRect;
 
//设置UITextField的代理
tf.delegate=self;
 
//设置UITextField的文字对齐方式
tf.textAlignment=UITextAlignmentCenter;//居中对齐
tf.textAlignment=UITextAlignmentLeft;//左对齐
tf.textAlignment=UITextAlignmentRight;//右对齐
tf.textAlignment=UITextAlignmentFill;//填充对齐
 
//设置UITextField的文字大小和字体
tf.font=[UIFont fontWithName:@"Times New Roman" size:20];
 
//设置左边距

{

CGRect frame = [text frame];

frame.size.width=8.0f;

[text setLeftView:[[UIView alloc]initWithFrame:frame]];

[text setLeftViewMode:UITextFieldViewModeAlways];

}

 
 
//设置UITextField自适应文本框大小
tf.adjustsFontSizeToFitWidth=YES/NO;//自适应宽度
tf.adjustsFontSizeToFitHeight=YES/NO;//自适应高度
 
//设置UITextField是否拥有一键清除的功能
tf.clearsOnBeginEditing=YES/NO;
 
//设置一键清除按钮是否出现
tf.clearButtonMode=UITextFieldViewModeNever;
 
//设置UITextField的初始隐藏文字
tf.placeholder=@"输入密码";
 
//当UITextField的样式为UITextBorderStyleNone的时候,修改背景图片
tf.background=[UIImage imageNamed:@"xx.png"];
 
//设置UITextField的左边view
tf.leftView=xxx;
 
//设置UITextField的左边view出现模式
tf.leftViewMode=UITextFieldViewModeAlways;
 
//设置UITextField的右边view
tf.rightView=xxx;
 
//设置UITextField的右边view出现模式
tf.rightViewMode=UITextFieldViewModeAlways;
 
//设置UITextField的字的摆设方式
tf.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;

UITextfield设置Placeholder颜色 控件 内边距、自适应高度的更多相关文章

  1. iOS UITextField设置placeholder颜色

    设置UITextField的placeholder颜色 UIColor *color = [UIColor blackColor]; textField.attributedPlaceholder = ...

  2. 【代码笔记】iOS-UITextField设置placeholder颜色

    一,效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> @interface RootViewController ...

  3. C#设置鼠标在控件上面时,改变光标形状

    //设置鼠标在控件上面时,改变光标形状 private void pictureBox_macroLogo_MouseHover(object sender, System.EventArgs e) ...

  4. C# WinForm窗体控件GroupBox修改边框颜色控件

    C# WinForm窗体控件GroupBox修改边框颜色控件 1.新建组件这里可以自定义一个GroupBox控件起名为GroupBoxEx 2.增加一个BoderColor属性 private Col ...

  5. 2019-9-2-win10-uwp-随着数字变化颜色控件

    title author date CreateTime categories win10 uwp 随着数字变化颜色控件 lindexi 2019-09-02 12:57:38 +0800 2018- ...

  6. 设置layui表格cell的内边距

    /*设置layui表格cell的内边距*/ .layui-table-cell { height: 50px !important; line-height: 50px !important; }

  7. 调整 CComboBox 控件的下拉列表的高度

    CComboBox 控件的下拉列表的高度默认很小,很难看.网上查来查去终于发现如何设置. 很巧妙,要在设计视图上单击下拉列表的小箭头.这时会发现出来的边框和点其它的位置是不同的. 这个高度就是下拉列表 ...

  8. Android在OnCreate中获取控件的宽度和高度

    在Android中,有时需要对控件进行测量,得到的控件宽度和高度可以用来做一些计算.在需要自适应屏幕的情况下,这种计算就显得特别重要.另一方便,由于需求的原因,希望一进入界面后,就能得到控件的宽度和高 ...

  9. UILabel,UITextField,UIButton三大基础控件总结

    (一)UILabel空件 属性: 1.背景颜色 label.backgroundColor = [UIColor ***]; 2. 显示文字: label.text = @"******&q ...

随机推荐

  1. I2C I2S SPDIF

    I2C总线 大多数是用于电视机等家用电器的(显卡与显示器之间的通讯也是)I2S: I2S(Inter—IC Sound)总线, 又称 集成电路内置音频总线,是飞利浦公司为数字音频设备之间的音频数据传输 ...

  2. xcopy 复制了0个文件

    xcopy /Y "..\..\..\SolutionItems\zbmyuncore.db" "..\ZITaker" 复制zbmyuncore.db文件的时 ...

  3. git同步远端的分支

    如果用命令行,运行 git fetch,可以将远程分支信息获取到本地, 再运行 git checkout -b local-branchname origin/remote_branchname  就 ...

  4. poj 2635 The Embarrassed Cryptographer(数论)

    题目:http://poj.org/problem?id=2635 高精度求模  同余模定理. 题意: 给定一个大数K,K是两个大素数的乘积的值.再给定一个int内的数L 问这两个大素数中最小的一个是 ...

  5. poj 2533 Longest Ordered Subsequence(dp)

    题目:http://poj.org/problem?id=2533 题意:最长上升子序列.... 以前做过,课本上的思想 #include<iostream> #include<cs ...

  6. Java [leetcode 10] Regular Expression Matching

    问题描述: Implement regular expression matching with support for '.' and '*'. '.' Matches any single cha ...

  7. mysql CMAKE 参数说明

    MySQL自5.5版本以后,就开始使用CMake编译工具了,因此,你在安装源文件中找不到configure文件是正常的.很多人下到了新版的MySQL,因为找不到configure文件,不知道该怎么继续 ...

  8. Android中全屏或者取消标题栏

    先介绍去掉标题栏的方法: 第一种:也一般入门的时候经常使用的一种方法 requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏 注意这句一定要写在se ...

  9. 在cshtml页面中,以‘@’开始的表达式 表示C#语句,会被编译执行

    在原始的Index.html中是正常显示的,然而在现在这个源代码是个cshtml页面: 但是在cshtml页面中,以‘@’开始的表达式 表示C#语句,会被编译执行,会去寻找controller传度给@ ...

  10. UVA 12436-Rip Van Winkle's Code(线段树的区间更新)

    题意: long long data[250001]; void A( int st, int nd ) { for( int i = st; i \le nd; i++ ) data[i] = da ...