[英]How to make an image view and a label adaptive to each other in swift
I have a UI View, which consists of image view and a label.我有一个 UI 视图,它由图像视图和标签组成。 UI view has constraints set up to the superview. UI 视图具有为超级视图设置的约束。 These labels are of different sizes,(data coming from backend) so I want to adjust the background image according to the length of the label.这些标签大小不同,(数据来自后端)所以我想根据标签的长度调整背景图像。
For example : Label : "Hi How are you" In this scenario - the image should fit the label and should look proportionate to the screen例如:标签:“嗨,你好吗”在这种情况下 - 图像应该适合标签并且看起来应该与屏幕成比例
Label : "Hi" In the scenario - the image should fit the label containing just "Hi", meaning it should shrink based on the label string length.标签:“Hi” 在场景中 - 图像应该适合只包含“Hi”的标签,这意味着它应该根据标签字符串长度缩小。
Is this possible ?这可能吗 ?
Follow these steps:按着这些次序:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.