在IOS程序中设置UIButton的字体大小
来源:互联网 发布:ubuntu标题栏透明 编辑:程序博客网 时间:2024/05/22 06:47
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];
附:创建按钮的两种方法:
1、动态创建
btnfont = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[btnfont setFrame:CGRectMake(100, 10, 120, 40)];
[btnfont addTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];
[btnfont setTitle:@"字体" forState:UIControlStateNormal];
btnfont.backgroundColor=[UIColor clearColor];
[self.view addSubview:btnfont];
2、在xib文件中已经创建好,通过tag获取按钮
UIButton *testButton= (UIButton*)[self.view viewWithTag:100];
[testButton addTarget:self action:@selector(test:) forControlEvents:UIControlEventTouchUpInside];
注册事件
-(void) test: (id) sender{
UIAlertView *av = [[[UIAlertView alloc] initWithTitle:@"ceshi" message:@"test11111" delegate:nil cancelButtonTitle:@"OK"otherButtonTitles:nil] autorelease];
[av show];
}
- 在IOS程序中设置UIButton的字体大小
- 在IOS程序中设置UIButton的字体大小
- 设置UIButton字体大小
- iOS设置改变UILabel、UIButton的多种颜色和字体大小(非常好用)
- 在eclipse中设置字体大小
- iOS在UIButton中换行
- iOS设置UIButton的字体
- iOS中UIButton的多种状态的隐藏设置
- iOS中UILabel和UIButton的自定义设置
- iOS开发-UIButton中title位置设置
- Swing中字体大小的设置,局部字体大小设置
- iOS中UIButton的block
- iOS中UIButton的使用
- ios中UIButton的使用
- 怎样在eclipse中设置字体大小
- 怎样在eclipse中设置字体大小
- 如何在eclipse中设置字体大小
- iOS开发webView设置字体大小的方法
- support vector machine -note from wiki
- coherent 和NoCoherent的正交IQ频率间隔
- u-boot学习(五):u-boot启动内核
- 代码分析工具推荐Understand
- java.util.concurrent包(4)——读写锁ReentrantReadWriteLock
- 在IOS程序中设置UIButton的字体大小
- Java Web Start为什么能加载pack.gz
- Nginx学习之一-第一个程序Hello World
- leetcode_Reverse Integer
- MongoDB的安装指南
- Numeral.js 是一个用于格式化和数字四则运算的js 库
- example of using ajax in VisualForce page
- android任务栈
- Linux常用命令大全