CALayer

时间:2022-04-08 23:18:07

刚刚无聊,画了一个月亮。

CALayer

- (void)viewDidLoad {

[super viewDidLoad];

self.view.layer.backgroundColor = [UIColor blackColor].CGColor;

CALayer *layer = [CALayer layer];

//尺寸

layer.bounds = CGRectMake(0, 0, 100, 100);

//中心点

layer.position = CGPointMake(250, 100);

//背景色

layer.backgroundColor = [UIColor blackColor].CGColor;

//设置圆角

layer.cornerRadius = 50.f;

[self.view.layer addSublayer:layer];

//阴影颜色

layer.shadowColor = [UIColor yellowColor].CGColor;

//阴影偏移量

layer.shadowOffset = CGSizeMake(10, 10);

//透明度

layer.shadowOpacity = 1;

}