How to align UILabel Horizontally with the profile photo image?

拈花ヽ惹草 提交于 2019-12-24 00:38:55

问题


I have to show the Name and EmailID aligned horizontally properly with the Profile Image . So that the Name and email ID appears exactlybat the center of the UIImageView.

But you can see the name and email id are not in centre with the profile image. Why is this happening? I have given the following constraints:


回答1:


Remove leading and trailing Constrain and set align center x to imageView.

You can also set leading and trailing Constrain. but both are equal as follow.




回答2:


Just control+drag from label to imageview and select Center Horizontally.




回答3:


Ctrl drag from the labels to the imageview and choose Center horizontally.




回答4:


I know the question has been answered but this is best solution horizontal stack view




回答5:


Ctrl+drag from image and labels to their superview and select Center Horizontally in Container.




回答6:


Using AutoResizing Tool:

Step1: Place your image view and labels exactly how do you needed.

Step2: Select Image view and click on Size Inspector.

Step3: Simply click on red bars of autoresizing subview to de-select it which is shown in below image.

Step4: Repeat same steps for labels. I made labels text alignment as centre.



来源:https://stackoverflow.com/questions/45768584/how-to-align-uilabel-horizontally-with-the-profile-photo-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!