简体   繁体   中英

How do I resize a constrained imageView, inside a table cell, in swift?

I have a table view controller with an image view, inside the prototype cell, which has various size/location constraints on it. I want to setup programatic view constraints but, because the cell is built and reloaded within the "cellForRowAtIndexPath" function I'm not sure how to set this up (I'm not sure where to declare the original constraints so I can update the .constant when each cell is reloaded).

For anyone coming across this: my solution was to create a IBOutlet, within the UITableViewCell. Then, when the cell is built, within cellForRowAtIndexPath, call the animation:

cell.itemRightSpace.constant = 100
cell.item1.layoutIfNeeded()

UIView.animateWithDuration(0.75, delay: 0.3, options: nil, animations: { () -> Void in

            cell.progress1RightSpace.constant = 0
            cell.progress1.layoutIfNeeded()

            }) { (isFinished) -> Void in }`

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM