UIView阴影不起作用 [英] UIView shadow not working

查看:79
本文介绍了UIView阴影不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码.

listView.layer.masksToBounds = NO;
listView.layer.shadowOffset = CGSizeMake(-3, 3);
listView.layer.shadowColor=[[UIColor blackColor] CGColor];
listView.layer.shadowRadius = 4;
listView.layer.shadowOpacity = 1.0;
[listView.layer setShouldRasterize:YES];

它具有阴影效果很好.

正在更改

listView.layer.masksToBounds = YES;

我没有得到阴影效果.

推荐答案

阴影实际上绘制在UIView下方.如果将maskToBounds设置为YES,则会在UIView框架之外裁剪任何图形. 此处是一个SO链接,对此进行了更详细的描述.

The shadow is actually drawn below the UIView. If you set maskToBounds to YES, this clips any drawing outside of the UIView frame. Here is a SO link that describes this in more detail.

这篇关于UIView阴影不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆