ios - UIView is sizing properly in dynamic UITableViewCell only after click -


i'm trying implement cardviews in uitableview, every table cell has uiview(named cardview) , context in uiview.

i'm adding shadow every cell in layoutsubviews() this:

cardview.layer.cornerradius = 3 cardview.layer.shadowcolor = uicolor.darkgraycolor().cgcolor cardview.layer.shadowoffset = cgsizemake(0,1) cardview.layer.shadowradius = 3 cardview.layer.shadowopacity = 0.5 cardview.layer.shadowpath = uibezierpath(rect: cardview.bounds).cgpath 

but result get:

screenshot

shadow sizing after click on it. suppose it's problem dynamically cells heights, can't handle this.

i created working example.

add code view controller:

    override func tableview(tableview: uitableview, willdisplaycell cell: uitableviewcell, forrowatindexpath indexpath: nsindexpath) {     let cel = cell as! tablecell     cel.setup() } 

add code tablecell:

    func setup() {     cardview.layer.maskstobounds = false     cardview.layer.cornerradius = 3     cardview.layer.shadowoffset = cgsizemake(0,1)     cardview.layer.shadowradius = 3     cardview.layer.shadowopacity = 0.3     cardview.layer.shadowpath = uibezierpath(rect: cardview.bounds).cgpath } 

Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -