设置UIButton的文字显示位置、字体的大小、字体的颜色
来源:互联网 发布:益盟爱炒股软件 编辑:程序博客网 时间:2024/04/29 09:11
btn.frame = CGRectMake(x, y, width, height);
[btn setTitle: @"search" forState: UIControlStateNormal];
//设置按钮上的自体的大小
//[btn setFont: [UIFont systemFontSize: 14.0]]; //这种可以用来设置字体的大小,但是可能会在将来的SDK版本中去除改方法
//应该使用
btn.titleLabel.font = [UIFont systemFontOfSize: 14.0];
[btn seBackgroundColor: [UIColor blueColor]];
//最后将按钮加入到指定视图superView
[superView addSubview: btn];
==========================================================
tvnamelabel=[[UIButton alloc]initWithFrame:CGRectMake(5,5,200,40)];
这样初始化的button,文字默认颜色是白色的,所有如果背景也是白色的话,是看不到文字的,
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的文字显示位置、字体的大小、字体的颜色
- arm处理器异常处理-swi
- HTML5人脸识别技术详解
- android之webview
- JSR-303规范,Bean Validation(spring mvc中如何校验)
- gallery中的图片没法点击,或者 glallery中的图片不能滑动但是能点击,用ontouch事件模拟onclick 点击事件
- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- 设置评分功能
- xcode4.3.1定制UITableviewCell实现类似微博的分组效果
- import 类名 cannot be resolved
- 【Android】ListView中getView的原理与解决多轮重复调用的方法
- Android中onCreateOptionsMenu()创建菜单Menu<学习笔记>
- XtraGrid使用教程整理+示例
- 移动应用市场2012年3大趋势:HTML5日渐成熟
- 动态调整UITableViewCell高度的实现方法