Xcode 6 Storyboard无法居中 [英] Xcode 6 Storyboard can't center

查看:384
本文介绍了Xcode 6 Storyboard无法居中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试将对象置于故事板中心时遇到了问题。我创建了一个新的单视图应用程序项目,输入了一个main.Storyboard,我正在尝试添加一个标签到它的中心。在4英寸iPhone的故事板预览中,标签不居中,即使我强迫故事板使用3.5,4或4.7英寸iPhone。添加约束没有任何区别。我做错了什么?

I have an issue trying to center an object in a storyboard. I've created a new "Single-view Application" project, entered a main.Storyboard and I'm trying to add a label to center of it. On a preview of this storyboard for 4-inch iPhone, the label isn't centered, even when I force storyboard to use 3.5, 4, or 4.7-inch iPhones. Adding constraints makes no difference. What am I doing wrong?

推荐答案

如果要垂直和水平居中标签,可以在故事板上使用对齐选项。在故事板的右下角,有四个选项,第一个是Align选项,选择它会让您选择对象的对齐方式,如下所示,

If you want to center the label vertically and horizontally, you can use Align option at the storyboard. On your storyboard's bottom right corner, there are four options and the first one is Align option, selecting it will give you to choose the alignment for your object as follows,

< img src =https://i.stack.imgur.com/yAltR.pngalt =对齐选项>

在屏幕截图中,您可以看到如果我想在两个维度中居中我的对象,我选择了两个选项。您可以根据自己的要求选择其中一个或两个,然后按添加2个约束按钮,它将适用于任何大小的屏幕。但是,在选择对齐选项之前,请务必选择要居中的对象。

Here in the screenshot, you can see that I have selected two options if I want to center my object in both dimension. You can choose either one of them or both based on your requirements and press Add 2 constraints button and it will work consistently for any sized screen. However make sure to select the object you want to center before selecting the Align option.

这篇关于Xcode 6 Storyboard无法居中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆