首页 文章

UIImageView不遵守UITableViewCell中的约束

提问于
浏览
1

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

enter image description here

增加的约束如下

enter image description here

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

enter image description here

如何让UiImageView遵循约束?

1 回答

  • 1

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

    imageView.clipsToBounds = true;
    

    这将解决您的问题 .

相关问题