⚠️注意
- 给
UIView
设置阴影时,如果UIView
设置了圆角,一定要把masksToBounds
设置为NO
,这时设置的阴影才会有效。
- 如果
UIView
设置了圆角,最好保证阴影的半径shadowRadius
跟UIView
设置圆角的半径一致;
示例代码如下:
self.customView.layer.cornerRadius = 8.0;
// 设置阴影一定要把masksToBounds/设置为NO
self.customView.layer.masksToBounds = NO;
//shadowColor阴影颜色
self.customView.layer.shadowColor = ColorSetWithAlpha(@"000000", 0.08).CGColor;
//shadowOffset阴影偏移
self.customView.layer.shadowOffset = CGSizeMake(0,0);
//阴影透明度
self.customView.layer.shadowOpacity = 0.8;
//阴影半径
self.customView.layer.shadowRadius = 8.0;
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。