设置UIButton的文字显示位置、字体的大小、字体的颜色
来源:互联网 发布:mac 终端 ssh 端口 编辑:程序博客网 时间:2024/05/24 06:22
btn.frame = CGRectMake(x, y, width, height);
[btn setTitle: @"search" forState: UIControlStateNormal];
//设置按钮上的自体的大小
btn.titleLabel.font = [UIFont systemFontOfSize: 14.0];
[btn setBackgroundColor: [UIColor blueColor]];
[superView addSubview: btn];
==========================================================
btn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft ;//设置文字位置,现设为居左,默认的是居中
[btn setTitle:@“title”forState:UIControlStateNormal];// 添加文字
有些时候我们想让UIButton的title居左对齐,我们设置
btn.textLabel.textAlignment = UITextAlignmentLeft
是没有作用的,我们需要设置
btn.contentHorizontalAlignment = UIControlContentHorizonAlignmentLeft;
但是问题又出来,此时文字会紧贴到做边框,我们可以设置
btn.contentEdgeInsets = UIEdgeInsetsMake(0,10, 0, 0);
使文字距离做边框保持10个像素的距离。
=======================================================
设置UIButton上字体的颜色设置UIButton上字体的颜色,不是用:
[btn.titleLabel setTextColor:[UIColorblackColor]];
btn.titleLabel.textColor=[UIColor redColor];
而是用:
[btn setTitleColor:[UIColor blackColor]forState:UIControlStateNormal];
- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- 设置UIButton的文字显示位置、字体的大小、字体的颜色 .
- 五月 25th, 2012设置UIButton的文字显示位置、字体的大小、字体的颜色
- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- UI:设置UIButton的文字显示位置、字体的大小、字体的颜色
- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- ios学习笔记:设置UIButton的文字显示位置、字体的大小、字体的颜色
- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- Android开发常见问题 不定期更新。开发环境Android Studio
- 离散化-等频等距
- 蓝桥杯往届试题--分糖果 简单的思维题目
- c++类学习
- HIVE 安装系列(3)配置HIVE 使用Mysql作为元数据的数据库
- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- 解读Google官方SwipeRefreshLayout控件源码,带你揭秘Android下拉刷新的实现原理
- [LeetCode]215. Kth Largest Element in an Array
- Cube逐点运动之动态增加节点
- 【转载】web.xml中load-on-startup的作用
- ios计算文字的大小
- MySQL SHOW INDEX语法的实际应用
- monit监控tomcat service
- 新老软件下载网站