【发布时间】:2016-11-20 23:20:40
【问题描述】:
我在 XIB 中创建了一个 tableviewcell,并通过注册类在 tableview 中使用它。我在这里使用autolayout。
但问题是当我在viewcontroller 中加载tableview 时,单元格内的视图阴影设置不正确。它超出了它的界限,如我用红色框显示的图片中所示。
但是当滚动 tableview 时,视图的阴影会按预期正确显示。
cellForRowAtIndexPath中使用的代码如下所示:
let layer = cell.cellContectView.layer
layer.shadowOffset = CGSizeMake(1.0, 1.0)
layer.shadowColor = UIColor.blackColor().CGColor
layer.shadowRadius = 5
layer.shadowOpacity = 0.2
layer.masksToBounds = false
layer.shadowPath = UIBezierPath(rect: layer.bounds).CGPath
请注意:文字模糊不是问题。出于安全原因将其隐藏
【问题讨论】:
标签: ios iphone swift uitableview autolayout