想要将UIButton设置背景色
来源:互联网 发布:计算睡眠网络断开 编辑:程序博客网 时间:2024/06/06 08:50
我是ios开发新手。
今天遇到一个问题,想要将UIButton设置背景色,结果发现只有将Type设置为UIButtonTypeCustom时,背景色才起作用。
但是此时,圆角效果却木有了……。网上搜索了半天,基本上都说通过layer的几个方法设置,但是copy代码后报错“Receivertype 'CALayer'forinstance message is a forward declaration”。
最后从一个老外的帖子里找到答案:
Add QuartzCore.framework to your project and this line to your .m file.
#import <QuartzCore/QuartzCore.h>
我的示例代码如下:
今天遇到一个问题,想要将UIButton设置背景色,结果发现只有将Type设置为UIButtonTypeCustom时,背景色才起作用。
但是此时,圆角效果却木有了……。网上搜索了半天,基本上都说通过layer的几个方法设置,但是copy代码后报错“Receivertype 'CALayer'forinstance message is a forward declaration”。
最后从一个老外的帖子里找到答案:
Add QuartzCore.framework to your project and this line to your .m file.
#import <QuartzCore/QuartzCore.h>
我的示例代码如下:
- UIButton *moreButton = [UIButton buttonWithType:UIButtonTypeCustom];
- moreButton.frame = CGRectMake(1.0f, 1.0f, cell.contentView.frame.size.width-2, cell.contentView.frame.size.height-2);
- [moreButton.layer setMasksToBounds:YES];
- [moreButton.layer setCornerRadius:10.0]; //设置矩形四个圆角半径
- [moreButton.layer setBorderWidth:1.0]; //边框宽度
- moreButton.backgroundColor = [UIColor clearColor];
- 想要将UIButton设置背景色
- UIButton设置高亮状态下的背景色【原创】
- 设置标题栏背景色,背景色是自定义背景色
- 设置背景色
- 设置对话框背景色
- 设置状态栏背景色
- OPENGL 设置背景色
- 设置Eclipse背景色
- notepad++设置背景色
- SecureCRT设置背景色
- 设置对话框背景色
- 网页背景色设置
- Android背景色设置
- Eclipse 设置背景色
- 设置webview背景色
- 设置IE背景色
- opengl 背景色设置
- 屏幕背景色设置
- 【练习07】 DFS 1011 蜘蛛牌
- uva 540 Team Queue
- C# 文件存在性判断
- RTX腾讯通基本功能
- Openfire 离线消息的处理机制
- 想要将UIButton设置背景色
- 1130-host ... is not allowed to connect to this MySql server
- FindingClosestObject
- mysql绑定参数bind_param原理以及防SQL注入
- Rand随机数产生
- 安装CentOS的建议
- android binder机制之--(我是Server Porxy)
- TableView详细解释
- 查看字符串在不同编码(ASCII、Unicode、UTF7、UTF8、Default、BigEndianUnicode)下的 Hex