新建一个项目,在storyboard中添加一个view.
1.通过layer设置边框的宽度和颜色
复制代码#import "YYViewController.h"
@interface YYViewController ()
@property (weak, nonatomic) IBOutlet UIView *customView;
@end
复制代码
@implementation YYViewController
- (void)viewDidLoad
{
[super viewDidLoad];
//设置边框的宽度为20
self.customView.layer.borderWidth=20;
//设置边框的颜色
self.customView.layer.borderColor=[UIColor greenColor].CGColor;
}
@end
2.通过layer设置边框为圆角
复制代码//设置layer的圆角
self.customView.layer.cornerRadius=20;
3.在layer上添加一张图片
复制代码#import "YYViewController.h"
@interface YYViewController ()
@property (weak, nonatomic) IBOutlet UIView *customView;













