1、在@interface中声明一个View;
<span style="font-size:24px;">@property (weak, nonatomic) IBOutlet UIView *redView;</span>
<span style="font-size:24px;">_redView.layer.cornerRadius = 50;//圆角半径
// _redView.layer.masksToBounds = YES;
_redView.layer.borderWidth = 2;
_redView.layer.borderColor = [UIColor whiteColor].CGColor;
_redView.layer.shadowColor = [UIColor yellowColor].CGColor;
_redView.layer.shadowOffset = CGSizeMake(10, 10);
_redView.layer.shadowOpacity = 1;</span>
3、创建一个黄色的长方形View,并设置其Layer;
<span style="font-size:24px;">UIView * rectView = [[UIView alloc]initWithFrame:CGRectMake(100, 300, 100, 200)];
[self.view addSubview:rectView];
rectView.backgroundColor = [UIColor yellowColor];
rectView.layer.cornerRadius = 50;</span>
效果如图: