UIImageView不遵守UITableViewCell中的约束

时间:2016-12-06 19:17:08

标签: ios xcode uitableview uiimageview ios-autolayout

我有一个简单的UITableViewController,tableview设置为static,我里面只有一个UITableViewCell,UITableViewCell有一个UIImageView,里面有一个标签。

enter image description here

添加的约束如下

enter image description here

当我运行这个应用程序时,一切看起来都很好,除了图像doest保持方形,UIIMageView失去其宽度和高度约束并显示整个图像。使用的比例类型是Aspect Fill。不确定附加的是结果

enter image description here

如何让UiImageView遵循约束?

1 个答案:

答案 0 :(得分:1)

从故事板中将clipsToBounds设置为true,或者您也可以通过编程方式将其设置为:

imageView.clipsToBounds = true;

这将解决您的问题。

相关问题