为UIButton设置边框等属性
来源:互联网 发布:mysql explain用法 编辑:程序博客网 时间:2024/04/28 04:30
declare your button:
then add:
The key code is setBorderWidth: Adapt as necessary... but note the border is manipulated prior to adding to as subview.
Also, make sure you:
into your .m file...
Code:
UIButton *downButton = [[UIButton alloc] initWithFrame:CGRectMake(60.0, 310.0, 55.0, 37.0)];[downButton setTitle:@"Name of Button" forState:UIControlStateNormal];[downButton setTitleColor:[UIColor blackColor] forState:UIControlEventTouchDown];[downButton.titleLabel setFont:[UIFont fontWithName:@"Times New Roman" size: 8]];[downButton addTarget:self action:@selector(downButtonPressed:) forControlEvents:UIControlEventTouchUpInside];[downButton setBackgroundColor:[UIColor darkGrayColor]];[downButton setTag:89];
Code:
CALayer * downButtonLayer = [downButton layer];[downButtonLayer setMasksToBounds:YES];[downButtonLayer setCornerRadius:10.0];[downButtonLayer setBorderWidth:1.0];[downButtonLayer setBorderColor:[[UIColor grayColor] CGColor]];[self.view insertSubview:downButton atIndex:upButton.tag];[downButton release];
Also, make sure you:
Code:
#import "QuartzCore/QuartzCore.h" // for CALayer
注意:
1、首先要定义一个button 按钮,button的tag属性一定要设置好。。。才能进行第二步的操作
2、其次加入CALayer代码
3、导入框架quartzCore.framework
拓展:
imageview 也可以用这种方法来为图片设置边框和边框的颜色
- 为UIButton设置边框等属性
- IOS设置UIView、UIButton等控件的边框设置为圆角
- 为手写UIButton、UITextField设置边框样式
- uibutton设置边框
- UIView,UIButton,UIImageView等设置圆角,设置阴影,设置边框的方法
- UIView,UIButton,UIImageView等设置圆角,设置阴影,设置边框的方法
- UIView,UIButton,UIImageView等设置圆角,设置阴影,设置边框的方法
- UIView,UIButton,UIImageView等视图设置圆角,设置阴影,设置边框的方法
- UIView,UIButton,UIImageView等设置圆角,设置阴影,设置边框的方法
- UIView,UIButton,UIImageView等设置圆角,设置阴影,设置边框的方法
- UIButton的边框颜色设置
- UIButton 属性设置
- XIB 设置UIView的圆角边框等属性
- 为UIButton添加边框,使用CALayer
- [IOS]UIButton 圆角/边框设置 相关
- UIButton圆角以及边框设置
- Ios UIButton 设置圆角和边框
- 关于StoryBord 中给UIButton 设置边框
- 使用Cobertura统计单元测试覆盖率
- 【Killua笔试面试题整理】两个数组a[N],b[N],其中A[N]的各个元素值已知,现给b[i]赋值
- 取得web工程WebRoot路径
- MKey 3G(学习笔记二)
- 谭浩强C++程序设计_指针习题11
- 为UIButton设置边框等属性
- Butterfly API注意事项一
- 通过wifi连接android设备的方法
- 25 让大家学会复用
- AS3 HorizontalScroller---- 水平滚动条控件,细节是魔鬼
- poi-2488 A Knight's Journey
- C++随手代码收藏 自定义实现 String 类
- Linux下的段错误产生的原因及调试方法
- js获取mac地址