UIButton的titleLabel

@property(nonatomic, readonly, retain) UILabel *titleLabel
 
Description - 描述
A view that displays the value of the currentTitle property for a button. (read-only)

显示当前的button的文本(只读)
Although this property is read-only, its own properties are read/write. Use these properties primarily to configure the text of the button.

虽然这个属性是只读的,但它自己的子属性是可读写的,你可以用他们来设置一些样式:

For example:
UIButton *button                  = [UIButton buttonWithType: UIButtonTypeSystem];
button.titleLabel.font            = [UIFont systemFontOfSize: 12];
button.titleLabel.lineBreakMode   = UILineBreakModeTailTruncation;

Do not use the label object to set the text color or the shadow color. Instead, use the setTitleColor:forState: and setTitleShadowColor:forState: methods of this class to make those changes.

不要直接用label对象来设置文本颜色以及阴影颜色.相对的,你可以使用方法setTitleColor:forState: setTitleShadowColor:forState: 来做这些改变.
The titleLabel property returns a value even if the button has not been displayed yet. The value of the property is nil for system buttons.

这个titleLabel属性能够返回值,即使这个button还没有被夹在,对于系统按钮而言,这个值为空.

你可以使用这个属性来与字符串比较判断哪个按钮别点击了.

UIButton的titleLabel的更多相关文章

  1. iOS 中UIButton的 settitle 和 titlelabel的使用误区

    UIButton中设置Titl方法包括以下几种: - (void)setTitle:(NSString *)title forState:(UIControlState)state; - (void) ...

  2. 设置UIButton或者UILabel显示文字的行数

    需要在UIButton的titleLabel或者UILabel的text 字符串里面添加换行符号 “\n”,并且设置 UILabel的numberOfLines属性 栗子:行数要和“\n”的个数对应, ...

  3. UIButton修改文字大小问题

    一.问题描述 通过UIButton对象font属性设置文字大小,却发现该属性在2.0.3.0就已经被废弃,ios不建议使用. 图1-1:点出UIButton对象的font属性提示被废弃 图1-2:UI ...

  4. UIButton关于setFont方法过时的解决方法

    环境:xcode7 语言:Object-c 解决方法:更改UIButton的titleLabel属性的font值 一.新建一个Single View Application项目 二.创建一个UIBut ...

  5. [iOS]详解调整UIButton的title和image的位置

    UIButton的默认布局是:title在右,image在左; 很多时候我们需要的是title在左边,或者title在下面,这时就需要调整UIButton的TitleLabel和ImageView的位 ...

  6. iOS 购物车动画

    代码地址如下:http://www.demodashi.com/demo/11155.html 先看看动画效果: 项目结构: 接下来开始具体实现过程: 一.先计算动画开始结束位置 方法:- (CGPo ...

  7. iOS swift 关于自定义表情键盘

    目录 输入框 键盘监听 键盘切换 表情装载 表情加载 表情输入 表情输出 表情显示 结束语 demo下载 demo图片: 输入框 为了让输入框能够随着用户输入内容变化自动变化高度,这里的输入框使用UI ...

  8. iOS学习-UIButton的imageView和titleLabel

    UIButton的imageView和titleLabel的位置设置通过setImageEdgeInsets和setTitleEdgeInsets来设置 参考:http://blog.csdn.net ...

  9. UIBUTTON titlelabel.text 不显示

    button.titlelabel.text=@"查询";设置后运行发现没事正确显示. 查找后原来UIButton分状态的,textLabel不管用 [button setTitl ...

随机推荐

  1. 02-oracle字符函数

    字符函数(scott/tiger 登陆) --upper(col name)将字符大写 --lower(col name)将字符小写 --initcap(col name)字符串的首字母大写,其余小写 ...

  2. sort sorted() reverse() reversed() 的区别1

    sort()是可变对象(字典.列表)的方法,无参数,无返回值,sort()会改变可变对象,因此无需返回值.sort()方法是可变对象独有的方法或者属性,而作为不可变对象如元组.字符串是不具有这些方法的 ...

  3. jacvascript 保留小数点

    //四舍五入保留2位小数(若第二位小数为0,则保留一位小数) function keepTwoDecimal(num) {  var result = parseFloat(num);  if (is ...

  4. Python中socket经ssl加密后server开多线程

            前几天手撸Python socket代码,撸完之后经过ssl加密,确保数据的安全,外加server端开启多线程保证一个客户端连接有一个线程来服务客户端,走了不少的弯路,网上的信息啥的要 ...

  5. Oracle PL/SQL编程之过程

    1.简介 过程用于执行特定的操作,当建立过程时,既可以指定输入参数(in),也可以指定输出参数(out),通过在过程中使用输入参数,可以将数据传递到执行部分,通过使用输出参数,可以将执行部分的数据传递 ...

  6. emacs 配置 clojure

    安装JDK,Version >= 6.0 java -version 2 安装EMACS,Version>=24 在脚本~/.emacs.d/init.el中增加如下内容 (require ...

  7. Mybatis多参数

    转载自:一杯甜酒 http://blog.csdn.net/u012562943/article/details/52316071 据我目前接触到的传多个参数的方案有三种.第一种方案 DAO层的函数方 ...

  8. C# 连接Oracle,进行查询,插入操作

    注:OracleConnection和OracleCommand已被标注为[弃用的],可以使用System.Data.OleDb.OleDbConnection代替OracleCOnnection,使 ...

  9. 文档类型DTD,DOCTYPE和浏览器模式

    出处:http://blog.csdn.net/freshlover/article/details/11616563 浏览器从服务端获取网页后会根据文档的DOCTYPE定义显示网页,如果文档正确定义 ...

  10. js返回树形结构数据

    /** * 树形结构转换 * @param a * @param idStr * @param pidStr * @param chindrenStr * @returns {Array} */ fu ...