标签:
//创建视图
UIView * view=[[[UIView alloc]init]autorelease];
view.frame=CGRectMake(0, 0, 270, 250);
view.backgroundColor=[UIColor whiteColor];
view.center=self.view.center;
[self.view addSubview:view];
//view的边框
CALayer * layer=[view layer];
[layer setMasksToBounds:YES]; //是否设置边框以及是否可见
[layer setBorderWidth:1.5]; //设置边框线的宽
[layer setBorderColor:[[UIColor blackColor] CGColor]]; //设置边框线的颜色
UIButton * button=[[UIButton alloc]init];
button.frame=CGRectMake(20, 180, 230, 50);
button.backgroundColor=[UIColor grayColor];
[view addSubview:button];
//按钮的边框
CALayer * layer1=[button layer];
[layer1 setMasksToBounds:YES]; //是否设置边框以及是否可见
[layer1 setBorderWidth:1.5]; //设置边框线的宽
[layer1 setBorderColor:[[UIColor blackColor] CGColor]]; //设置边框线的颜色
ps:大写的view和button可以替换成各种控件~
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/qq_27364431/article/details/47974035