//swift3.0,如果是2.0的话也可以照着这个样子去写,语法有所变动。根据联想出来的就可以了。

let tx = UITextField(frame: CGRect(x: 100, y: 100, width: 100, height: 100))

tx.borderStyle = UITextBorderStyle.roundedRect

//所有类型

//        typedef enum {

//            UITextBorderStyleNone,

//            UITextBorderStyleLine,

//            UITextBorderStyleBezel,

//            UITextBorderStyleRoundedRect

//        } UITextBorderStyle;

tx.layer.borderWidth = 1; //边框的宽度

tx.layer.borderColor = UIColor.green.cgColor //边框的颜色,也可以自己定义颜色,可以使用 R,G,B了比如

//        tx.layer.borderColor = UIColor(red: 225/225.0, green: 30/225.0, blue: 40/225.0, alpha: 1.0).cgColor

view.addSubview(tx)

2.0扩展,字体的设置(加粗倾斜等)

label.font=[UIFont fontWithName:@"ArialMT"size:24];
//fontWithName处字体不知道名字,可以看下面图片字体对照!

1.字体名如下(图片对照在最下面):

Font Family: American Typewriter
Font: AmericanTypewriter
Font: AmericanTypewriter-Bold Font Family: AppleGothic
Font: AppleGothic Font Family: Arial
Font: ArialMT
Font: Arial-BoldMT
Font: Arial-BoldItalicMT
Font: Arial-ItalicMT Font Family: Arial Rounded MT Bold
Font: ArialRoundedMTBold Font Family: Arial Unicode MS
Font: ArialUnicodeMS Font Family: Courier
Font: Courier
Font: Courier-BoldOblique
Font: Courier-Oblique
Font: Courier-Bold Font Family: Courier New
Font: CourierNewPS-BoldMT
Font: CourierNewPS-ItalicMT
Font: CourierNewPS-BoldItalicMT
Font: CourierNewPSMT Font Family: DB LCD Temp
Font: DBLCDTempBlack Font Family: Georgia
Font: Georgia-Bold
Font: Georgia
Font: Georgia-BoldItalic
Font: Georgia-Italic Font Family: Helvetica
Font: Helvetica-Oblique
Font: Helvetica-BoldOblique
Font: Helvetica
Font: Helvetica-Bold Font Family: Helvetica Neue
Font: HelveticaNeue
Font: HelveticaNeue-Bold Font Family: Hiragino Kaku Gothic **** W3
Font: HiraKakuProN-W3 Font Family: Hiragino Kaku Gothic **** W6
Font: HiraKakuProN-W6 Font Family: Marker Felt
Font: MarkerFelt-Thin Font Family: STHeiti J
Font: STHeitiJ-Medium
Font: STHeitiJ-Light Font Family: STHeiti K
Font: STHeitiK-Medium
Font: STHeitiK-Light Font Family: STHeiti SC
Font: STHeitiSC-Medium
Font: STHeitiSC-Light Font Family: STHeiti TC
Font: STHeitiTC-Light
Font: STHeitiTC-Medium Font Family: Times New Roman
Font: TimesNewRomanPSMT
Font: TimesNewRomanPS-BoldMT
Font: TimesNewRomanPS-BoldItalicMT
Font: TimesNewRomanPS-ItalicMT Font Family: Trebuchet MS
Font: TrebuchetMS-Italic
Font: TrebuchetMS
Font: Trebuchet-BoldItalic
Font: TrebuchetMS-Bold Font Family: Verdana
Font: Verdana-Bold
Font: Verdana-BoldItalic
Font: Verdana
Font: Verdana-Italic Font Family: Zapfino
Font: Zapfino

这里写图片描述

修改textField的placeholder的字体颜色、大小

使用KVO实现

textField.placeholder = @”username is in here!”; 
[textField setValue:[UIColor redColor] forKeyPath:@”_placeholderLabel.textColor”]; 
[textField setValue:[UIFont boldSystemFontOfSize:16] forKeyPath:@”_placeholderLabel.font”];

swift设置textfield边框颜色的更多相关文章

  1. iOS开发--UIButton 设置圆角 边框颜色 点击回调方法

    UIButton *signBtn = [UIButton buttonWithType:UIButtonTypeCustom]; signBtn.frame = CGRectMake(, , , ) ...

  2. UIButton 设置圆角 边框颜色 点击回调方法

    UIButton *signBtn = [UIButton buttonWithType:UIButtonTypeCustom]; signBtn.frame = CGRectMake(, , , ) ...

  3. JAVA swing中JPanel如何实现分组框的效果以及设置边框颜色 分类: Java Game 2014-08-16 12:21 198人阅读 评论(0) 收藏

    代码如下: import java.awt.FlowLayout; import java.awt.Frame; import java.awt.GridLayout; import javax.sw ...

  4. css盒子模型之边框宽度,边框颜色与边框样式

    /* width和height只是设置盒子内容区的大小,而不是盒子的整个大小, 盒子可见框的大小由内容区,内边距和边框共同决定. */ .box1 { /* 设置内容区的宽度为400px */ wid ...

  5. winform设置button的边框颜色,或取消边框颜色,不显示边框

    // winform设置边框颜色不像webform那么简单,可以通过设置FlatAppearance,也可以通过重绘实现. 一.设置按钮本身属性 buttonBubufx.FlatStyle = Fl ...

  6. UIButton设置圆角和边框及边框颜色

    1. 按钮边框颜色 //设置边框颜色 [btn.layer setMasksToBounds:YES]; [btn.layer setCornerRadius:10.0]; //设置矩形四个圆角半径 ...

  7. 使用storyboard设置button边框属性(颜色,宽度,圆角)

    通常使用Category时.仅仅能加入方法,不可加入属性.可是在使用Storyboard时我们可能会使用到keyPath,这里设置的key都须要是所设置视图的属性值.而且类型有所限制. 比如:我如今有 ...

  8. zxing生成二维码设置边框颜色

    真是研究了很久很久,满满的泪啊 zxing生成二维码,默认是可以增加空白边框的,但是并没有可以设置边框颜色的属性. 其中增加空白边框的属性的一句话是: Map hints = new HashMap( ...

  9. 设置UI控件的Layer属性(边框可见,边框颜色,边框宽度,边框圆角)

    设置UI控件的Layer属性 #import "ViewController.h" @interface ViewController () @property (strong, ...

随机推荐

  1. Windows 7硬盘安装CentOS 6.4 双系统 (WIN7硬盘安装Linux(Fedora 16,CentOS 6.2,Ubuntu 12.04))

     WIN7下硬盘安装Linux(Fedora 16,CentOS 6.2.Ubuntu 12.04) 近期在看<鸟哥私房菜:基础学习篇>.认为非常不错,想要用U盘装个windows 7 和 ...

  2. MongoDB的C#驱动

    MongoDB的C#驱动基本使用 MongoDB的官方C#驱动可以通过这个链接得到.链接提供了.msi和.zip两种方式获取驱动dll文件. 通过这篇文章来介绍C#驱动的基本数据库连接,增删改查操作. ...

  3. ProvissyTool Update Support Page

    DO NOT REPLY. ############# #??????# ############

  4. Knockout简单用法

    Knockout简单用法 在最近做的一个项目中,页面数据全部通过js ajax调用webapi接口获取,也就是说页面的数据全部使用javascript脚本填充,这就想到了使用一个MVVM模式的js框架 ...

  5. 基于C++11线程池

    1.包装线程对象 class task : public std::tr1::enable_shared_from_this<task> { public: task():exit_(fa ...

  6. ref引用类型,数组型参数,out输出参数

    ref和out的相同点和不同点 共同点:都是引用传递不同点:ref的参数在调用之前一定要赋值,在方法调用的过程中可以不要赋值.    out的参数在调用之前可以不赋值,在方法调用的过程中一定要赋值. ...

  7. EasyUi的快速开发框架

    基于EasyUi的快速开发框架   先看图,下边这个简单的增.删.改.查,如果自己写代码实现,这两个页需要多少行代码? 如果再有类似的增.删.改.查,又需要多少行代码? 我最近搞的这个快速开发框架中, ...

  8. Visual Studio 换颜色

    --- 给 Visual Studio 换颜色 “为革命,保护视力,预防近视,眼保健操开始......” 这个应该是最老版本的眼保健操了,你听过? 一堆废话 且不说上面这个眼保健操到底有木有用,让眼睛 ...

  9. Visual Studio 自定义项目或工程模板

    如何利用 Visual Studio 自定义项目或工程模板 在开发项目的时候,由其是商业性质的大型项目时,往往需要在每个代码文件上都加上一段关于版权.开发人员的信息,并且名称空间上都需要带有公司的标志 ...

  10. 项目管理Project

    使用Project进行项目管理 - 项目管理系列文章 Posted on 2014-02-04 11:59 lzhdim 阅读(1175) 评论(0) 编辑 收藏 本系列文章列表地址:http://w ...