简体   繁体   English

将标签彼此重叠放置在图像旁边

[英]Place label on top of each other next to an image

I'm trying to place a label on top of label next to my image. 我正在尝试在图片旁边的标签上方放置一个标签。

在此处输入图片说明

I have tried 我努力了

在此处输入图片说明

I had 我有

在此处输入图片说明

I want these number to display here 我希望这些数字显示在这里

在此处输入图片说明

Should I look into a stack or some short? 我应该看一堆还是短一些?

In this case, I might be tempted to just use a UIStackView - it might be a little overkill, but one of the benefits is if you hide one of the labels (because it's text is nil) it will reduce the size of the StackView , which, personally, makes the layout look nicer, but that's me 在这种情况下,我可能会想只使用UIStackView可能有点过大,但是好处之一是,如果隐藏其中一个标签(因为它的文本为nil),它将减小StackView的大小,就个人而言,这使布局看起来更好,但这就是我

General layout... 总体布局...

总体布局

UIImageView constraints UIImageView约束

UIImageView约束

UIStackView constraints UIStackView约束

StackView约束

UIStackView properties UIStackView属性

UIStackView属性

*nb: This still assumes that the overall height of the text won't exceed the height of the UIImageView * nb:这仍然假设文本的整体高度不会超过UIImageView的高度

Based on your requirement, I created it in storyboard; 根据您的要求,我在情节提要中创建了它; u can do same like it to achieve your prototype : 你可以做同样的事情来实现你的原型:

  • Constraints for label 2 (Devices): 标签2(设备)的约束:

在此处输入图片说明

  • Constraints for Label 1 (John) : 标签1(John)的约束:

在此处输入图片说明

I hope it clears your doubt. 希望它能消除您的疑问。

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

相关问题 如何在React Native中将图像放在其他图像的顶部? - How to place an Image on top of other Image in React Native? 将图片放在另一张图片上 - Place an image on top of another image 如何快速使图像视图和标签相互适应 - How to make an image view and a label adaptive to each other in swift 将三个UILabel彼此相邻排列,每个标签可以是多行 - Line up three UILabels next to each other and each label can be multiline 为什么我不能在第一次运行时在UISplitViewController中将Master和Detail视图彼此相邻放置,但是在轮换时它可以工作? - Why can I not place Master and Detail view next to each other in UISplitViewController on the first run, but upon rotation it works? UIButton:将图片放在标题旁边 - UIButton: place image next to the title 布局设计的哪些场景需要动态高度 label 和彼此相邻的文本字段? - what scenarios of layout design needs Dynamic height label and a text field next to each other? 将标签放置在spaceBetweenPoints中的每个点下方 - Place Label under each point from spaceBetweenPoints 在scrollview中的每个元素上方放置标签? - Place label above each element in scrollview? 如何将UIView放在其他UIView之上? - How to place UIView on top of other UIView?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM