实现卡片样式的 table cell 设置 shadow 时候显示异常
写了个 Demo ,放在 https://github.com/neil-wu/TestCardShadow
问题:初始化显示后, shadow 的位置并不正确,如下图,需要再次 reload 一下就正常了。

有遇到过类似问题的朋友,求指导。
大家都是怎么实现类似的阴影效果呢?
这个 Demo 没有出现的另外一个问题是:滑动 table 后, cell 重新出现时它的阴影看不到了。
设置 shadow 的代码如下:
let shadowLayer = self.cardBgView.layer
shadowLayer.shadowOffset = CGSizeMake(1, 1)
shadowLayer.shadowRadius = 3.0
shadowLayer.shadowColor = UIColor.grayColor().CGColor
shadowLayer.shadowOpacity = 0.5
let shadowSize = self.cardBgView.bounds.size
shadowLayer.shadowPath = UIBezierPath(rect: CGRectMake(2, 2, shadowSize.width, shadowSize.height)).CGPath