XCode 7 - Misplaced views warning for view in Storyboard

孤人 提交于 2019-12-25 16:24:13

问题


I have added a UIView on storyboard in which i set a constraints to top,left,bottom,right as shown below

As you can see in the image, orange bordered line indicates that i misplaced the view.

My UIView position is 0,20,320,150. I am not sure why xcode shows the warning eventhough i set a correct constraint.

I am using Xcode 7 beta version.


回答1:


Your constraints doesn't respect you frame.
You have frame 0, 20, 320, 150, but constraints show Trailing Space: -20 and Leading Space: -20. Set both of them to -16 and warnings will disappear.
You need set -16 because your constraints related to margins, not to actual bounds. Margin has 16 points offset from bounds.



来源:https://stackoverflow.com/questions/31749947/xcode-7-misplaced-views-warning-for-view-in-storyboard

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