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. centos 7安装phpMyadmin

    1.phpmyadmin官网下载多语言包 2.找到libraries目录下的config.default.php1)查找$cfg['PmaAbsoluteUri'] 设置默认访问网址 2)查找$cfg ...

  2. Flexbox 完全指南

    Flexbox 完全指南 我不是这篇文章的原创作者,我只是好文章的搬运工.原文地址 A Complete Guide to Flexbox 应用于 flex container 的属性 display ...

  3. Apache 配置虚拟域名的最简单方式

    一.配置httpd.conf: 1.取消Include conf/extra/httpd-vhosts.conf的注释,代码如下: # Virtual hostsInclude conf/extra/ ...

  4. CentOS7 配置免密登陆

    首先我通过VMware配置了4台机器 然后依次更改每台机器的hosts文件为:   (/etc/hosts) 192.168.32.128 linux1192.168.32.130 linux2192 ...

  5. ZOJ 2856 Happy Life

    Problem Description Do you know Utopia? It's a perfect world in which everyone leads a happy life. A ...

  6. WPF的DatePicker--日期选择器

    1. 日期选择器 DatePicker, 如图: 点击打开后显示如下: 2. 关键属性 SelectedDate SelectedDate属性, DateTime? 类型(可为空的DateTime类型 ...

  7. [tools]转载汇总

    1. 发送请求工具—Advanced REST Client Advanced REST Client是Chrome浏览器下的一个插件,通过它可以发送http.https.WebSocket请求.

  8. Echarts 修改折线的颜色和折线的点的大小方法

    series: [{ type: 'line', smooth:true,//折点是圆弧状的                            showSymbol: true,          ...

  9. jquery 使用整理

    1. 如何创建嵌套的过滤器 //允许你减少集合中的匹配元素的过滤器, //只剩下那些与给定的选择器匹配的部分.在这种情况下, //查询删除了任何没(:not)有(:has) //包含class为“se ...

  10. Expression Blend实例中文教程(5) - 布局控件快速入门StackPanel,ScrollViewer和Border

    上一篇,介绍了Canvas布局控件在Blend中的使用.本篇继续介绍布局控件StackPanel,ScrollViewer和Border. 相对于Grid和Canvas来说,StackPanel,Sc ...