UIButton
来源:互联网 发布:淘宝详情页是多少 编辑:程序博客网 时间:2024/06/05 18:36
btn.frame = CGRectMake(x, y, width, height);
[btn setTitle: @"search" forState: UIControlStateNormal];
//设置按钮上的自体的大小
//[btn setFont: [UIFont systemFontSize:14.0]];
//应该使用
btn.titleLabel.font = [UIFontsystemFontOfSize: 14.0];
[btn seBackgroundColor:[UIColor blueColor]];
//最后将按钮加入到指定视图superView
[superView addSubview: btn];
==========================================================
tvnamelabel=[[UIButtonalloc]initWithFrame:CGRectMake(5,5,200,40)];
这样初始化的button,文字默认颜色是白色的,所有如果背景也是白色的话,是看不到文字的,
btn.contentHorizontalAlignme
[btn setTitle:@“title”forState:UIControlStateNormal];// 添加文字
有些时候我们想让UIButton的title居左对齐,我们设置
btn.textLabel.textAlignment = UITextAlignmentLeft
是没有作用的,我们需要设置
btn.contentHorizontalAlignme
但是问题又出来,此时文字会紧贴到做边框,我们可以设置
btn.contentEdgeInsets =UIEdgeInsetsMake(0,10, 0, 0);
使文字距离做边框保持10个像素的距离。
=======================================================
设置UIButton上字体的颜色设置UIButton上字体的颜色,不是用:
[btn.titleLabel setTextColor:[UIColorblackColor]];
btn.titleLabel.textColor=[UIColor redColor];
而是用:
[btn setTitleColor:[UIColorblackColor]forState:UIControlStateNormal];
- UIButton
- UIButton
- UIButton
- uibutton
- UIButton
- UIButton
- UIButton
- UIButton
- UIButton
- UIButton
- UIBUTTON
- UIButton
- UIButton
- UIButton
- UIBUTTON
- UIButton
- UIButton
- UIButton
- 绘图
- 数据库迁移,SqlServer2008R2迁移到ORA10g
- NSNotification使用
- 转载别人的笔记,内容丰富。
- Iphone实现截屏的方法
- UIButton
- 正则表达式
- 多线程(四)_多线程互动
- MyBatis入门(一)
- 16进制转色值
- 铃声
- arc
- iOS正则表达式
- iOS应用内付费(IAP)开发步骤列表