iOS控件周围阴影

废话不多说,直接上代码:

    UIView  * shadowView = [[UIView alloc]initWithFrame:CGRectMake(100, 200, 200, 100)];
    shadowView.backgroundColor = [UIColor whiteColor];
    shadowView.layer.shadowColor =[UIColor grayColor].CGColor;  // 阴影颜色
    shadowView.layer.shadowOpacity = 1; // 阴影透明度,默认0
    shadowView.layer.shadowOffset = CGSizeZero; // 设置偏移量0,代表四周都有阴影
    shadowView.layer.shadowRadius = 20.0; // 阴影半径,默认是 3
    shadowView.layer.cornerRadius = 50;
    shadowView.layer.masksToBounds = NO;
    [self.view addSubview:shadowView];

效果如下:


image.png
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容