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. 透视效果shader(边缘光)

    思路:渲染两次. 1.第一次渲染:利用Greater进行深度测试,当目标被遮挡时,用一个边缘光的效果显示. 2.第二次渲染:正常渲染. 边缘光的思路:观察方向和顶点法向量夹角越大,边缘光越明显.边缘光 ...

  2. django notes 二:URL dispatcher

    一般在 settings.py 中会有一个  ROOT_URLCONF ,请求到来时 django 会从 ROOT_URLCONF 指向的文件中查找  urlpatterns 变量配置的路由. url ...

  3. sencha touch overlay 里使用 list

    1 sencha touch 中 list 如果不设置一个固定高度或 flex : 1,  list 的内容就不会显示出来. 主要是因为 list 是可滚动的,你不设置高度 ,list 的高度默认就是 ...

  4. orcale 之 SQL 数据查询

    从数据库中检索行,并允许从一个或多个表中选择一个或多个行或列.虽然 SELECT 语句的完整语法较复杂,但是其主要的子句可归纳如下: SELECT select_list [ INTO new_tab ...

  5. 【c++】explicit 隐式类类型转换

    上代码 #include <iostream> #include <sstream> using namespace std; class A { public: A(cons ...

  6. sql创建表变量,转百分数

    declare @tab table( ID nt identity(1,1) primary key, --从1开始,每次自增1 ,Name nvarchar(200) ) declare a fl ...

  7. JS 中的require 和 import 区别整理

    ES6标准发布后,module成为标准,标准的使用是以export指令导出接口,以import引入模块,但是在我们一贯的node模块中,我们采用的是CommonJS规范,使用require引入模块,使 ...

  8. Java实现在线预览–openOffice实现

    实现逻辑有两种: 一.利用jodconverter(基于OpenOffice服务)将文件(.doc..docx..xls..ppt)转化为html格式. 二.利用jodconverter(基于Open ...

  9. Python基础学习总结(五)

    7.用户输入输出和while循环 1.使用函数 input() 输入,print() 打印,字符串可以用逗号隔开.end=' ' 关键字参数,打印时可以不换行,sep=‘ 你想要的分隔符 ’,关键字参 ...

  10. easypoi导出单个sheet和多个sheet

    今天有时间研究了一下easypoi,感觉使用了easypoi导出excel方便了很多,不用写很多复杂的反射,只需要使用注解和一些工具类就可以实现常用的excel的导出,接下来介绍一下easypoi如何 ...