但是如果把masksToBounds设置为yes就没有阴影了
UIButton *view = [[UIButton alloc]initWithFrame:CGRectMake(
100,
100,
100,
100)];
view.backgroundColor = [UIColor redColor];
view.layer.shadowColor = [[UIColor grayColor] CGColor]; // 阴影的颜色
view.layer.shadowOpacity = 0.5f; // 阴影透明度
view.layer.shadowOffset = CGSizeMake( 10.0, 10.0f); // 阴影的范围
view.layer.shadowRadius = 5; // 阴影扩散的范围控制
view.layer.cornerRadius = 10;
// view.layer.masksToBounds = YES;
[self.view addSubview:view];
view.backgroundColor = [UIColor redColor];
view.layer.shadowColor = [[UIColor grayColor] CGColor]; // 阴影的颜色
view.layer.shadowOpacity = 0.5f; // 阴影透明度
view.layer.shadowOffset = CGSizeMake( 10.0, 10.0f); // 阴影的范围
view.layer.shadowRadius = 5; // 阴影扩散的范围控制
view.layer.cornerRadius = 10;
// view.layer.masksToBounds = YES;
[self.view addSubview:view];