iOS 圆角 阴影
2020-08-05 本文已影响0人
松龄学编程
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
CALayer *layer = [CALayer layer];
layer.name = @"shadow";
layer.frame = self.containerView.frame;
layer.backgroundColor = [UIColor whiteColor].CGColor;
layer.shadowOffset = CGSizeZero;
layer.shadowColor = [[UIColor lightGrayColor] CGColor];
layer.shadowOpacity = 0.8;
layer.shadowRadius = 6;
layer.cornerRadius = 20;
[self.view.layer insertSublayer:layer atIndex:0];
self.shadow = layer;
});