UIButton3
来源:互联网 发布:安润金融 知乎 编辑:程序博客网 时间:2024/06/03 17:29
// 内容偏移- (void)test9 { UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; button.frame = CGRectMake(100, 100, 200, 200); // button.backgroundColor = [UIColor redColor]; button.backgroundColor = [UIColor lightGrayColor]; [button setBackgroundImage:[UIImage imageNamed:@"屏幕快照 2015-08-23 上午11.13.46"] forState:UIControlStateNormal]; [button setTitle:@"hello" forState:UIControlStateNormal]; // contentEdgeInsets 整体内容偏移 // imageEdgeInsets image偏移 // titleEdgeInsets title偏移 button.contentEdgeInsets = UIEdgeInsetsMake(100, 0, 0, 0); // button.imageEdgeInsets = UIEdgeInsetsMake(0, 20, 0, 0); [self.view addSubview:button];}// 关于UIButton的圆角 边框颜色 回调方法- (void)test8 { // 当使用custom类型的button的时候,你可以指定按钮的背景色,但是当你运行时 // 按钮就失去了圆角特性,你看到的仅仅是一个方块。 // custombutton没有定义任何属性默认值,我们必须自己去定义他们。这就需要使用到了 // core animation layer UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; [self.view addSubview:btn]; btn.frame = CGRectMake(100, 100,100, 100); // layer 图层 // maskstobounds 告诉layer将位于它之下的layer都遮盖掉 [btn.layer setMasksToBounds:YES]; // cornerRadius 圆角半径 [[btn layer] setCornerRadius:8.0f]; // borderwidth 设置边框宽度 默认边框颜色为黑色 [[btn layer] setBorderWidth:1.0f]; // 设置边框颜色 CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGColorRef colorRef = CGColorCreate(colorSpace, (CGFloat[]){1,0,0,1}); [btn.layer setBorderColor:colorRef]; }
0 0
- UIButton3
- autorelease用法
- 关于Myeclipse导入ExtJS出错的问题解决:
- SQL中char、varchar、text区别
- 窗口、视口、屏幕显示详解
- tomcat负载均衡
- UIButton3
- lightoj 1044 Palindrome Partitioning(dp)
- 更改myeclipse中的@author
- No Java runtime present, requesting install.
- POJ 2528 Mayor's posters(线段树成段更新+离散化)
- Memcached 的静态编译(Mac OS X)
- Permutation Sequence
- Oracle数据的启动与关闭
- 机器学习:搜索引擎过渡至人工智能