简体   繁体   English

如何快速调整表格单元格内受约束的imageView的大小?

[英]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). 我想设置程序化视图约束,但是由于单元是在“ cellForRowAtIndexPath”函数中生成并重新加载的,因此我不确定如何设置(我不确定在哪里声明原始约束,因此可以更新。)每个单元重新加载时为常数)。

For anyone coming across this: my solution was to create a IBOutlet, within the UITableViewCell. 对于遇到此问题的任何人:我的解决方案是在UITableViewCell中创建IBOutlet。 Then, when the cell is built, within cellForRowAtIndexPath, call the animation: 然后,在构建单元时,在cellForRowAtIndexPath中调用动画:

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 }`

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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