故事板如何把控件/小部件放在顶部?

时间:2016-01-17 03:54:47

标签: ios storyboard

我已经隐藏了状态栏并设置了约束。

我希望标记"登录"到某个高度,但在运行应用程序时,高度不是我设置的。

故事板源代码在这里:

                   <!--Login-->
    <scene sceneID="khL-mS-4U7">
        <objects>
            <viewController id="eG8-k9-KdS" customClass="Login" customModule="FoodOrderingSystem" customModuleProvider="target" sceneMemberID="viewController">
                <layoutGuides>
                    <viewControllerLayoutGuide type="top" id="Owo-p5-rBQ"/>
                    <viewControllerLayoutGuide type="bottom" id="dOD-R1-W9P"/>
                </layoutGuides>
                <view key="view" contentMode="scaleAspectFill" id="Eda-3z-eWo">
                    <rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
                    <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                    <subviews>
                        <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Log in" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Q8d-5R-XXC">
                            <rect key="frame" x="0.0" y="0.0" width="600" height="25"/>
                            <color key="backgroundColor" red="0.98563787037676764" green="0.98563787037676764" blue="0.98563787037676764" alpha="1" colorSpace="calibratedRGB"/>
                            <constraints>
                                <constraint firstAttribute="height" constant="25" id="chN-3p-wiS"/>
                            </constraints>
                            <fontDescription key="fontDescription" name="HiraginoSans-W3" family="Hiragino Sans" pointSize="19"/>
                            <color key="textColor" red="0.29803922770000002" green="0.29803922770000002" blue="0.29803922770000002" alpha="1" colorSpace="calibratedRGB"/>
                            <nil key="highlightedColor"/>
                        </label>
                        <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="M8b-aM-Sop">
                            <rect key="frame" x="20" y="-2" width="60" height="30"/>
                            <constraints>
                                <constraint firstAttribute="width" constant="60" id="faK-bg-eDw"/>
                            </constraints>
                            <fontDescription key="fontDescription" name="HiraginoSans-W3" family="Hiragino Sans" pointSize="13"/>
                            <state key="normal" title="Dismiss">
                                <color key="titleColor" red="0.94901960780000005" green="0.44705882349999998" blue="0.25882352939999997" alpha="1" colorSpace="calibratedRGB"/>
                            </state>
                            <connections>
                                <action selector="dismissLoginDialog:" destination="eG8-k9-KdS" eventType="touchUpInside" id="nky-Yy-z9o"/>
                            </connections>
                        </button>
                        <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Welcom back, log in to get started." textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Wk8-BF-NOh">
                            <rect key="frame" x="174" y="100" width="253" height="21"/>
                            <constraints>
                                <constraint firstAttribute="height" constant="21" id="YEV-ae-Qhe"/>
                                <constraint firstAttribute="width" constant="253" id="Yly-vH-0Fy"/>
                            </constraints>
                            <fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="16"/>
                            <color key="textColor" red="0.098039217289999994" green="0.098039217289999994" blue="0.098039217289999994" alpha="1" colorSpace="calibratedRGB"/>
                            <nil key="highlightedColor"/>
                        </label>
                        <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Klu-9Y-Iay">
                            <rect key="frame" x="125" y="130" width="350" height="1"/>
                            <color key="backgroundColor" red="0.50196081400000003" green="0.50196081400000003" blue="0.50196081400000003" alpha="1" colorSpace="calibratedRGB"/>
                            <constraints>
                                <constraint firstAttribute="height" constant="1" id="GPb-Rc-itP"/>
                                <constraint firstAttribute="width" constant="350" id="sx6-io-hO4"/>
                            </constraints>
                            <fontDescription key="fontDescription" type="system" pointSize="17"/>
                            <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
                            <nil key="highlightedColor"/>
                        </label>
                        <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder=" Email" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="dO5-c4-J8f">
                            <rect key="frame" x="25" y="160" width="550" height="30"/>
                            <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
                            <constraints>
                                <constraint firstAttribute="height" constant="30" id="ZBh-dO-UUL"/>
                            </constraints>
                            <color key="textColor" red="0.20000000300000001" green="0.20000000300000001" blue="0.20000000300000001" alpha="1" colorSpace="calibratedRGB"/>
                            <fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="14"/>
                            <textInputTraits key="textInputTraits" keyboardType="emailAddress" returnKeyType="done"/>
                            <userDefinedRuntimeAttributes>
                                <userDefinedRuntimeAttribute type="color" keyPath="layer.borderColor">
                                    <color key="value" red="0.50196081400000003" green="0.0" blue="0.25098040700000002" alpha="1" colorSpace="calibratedRGB"/>
                                </userDefinedRuntimeAttribute>
                            </userDefinedRuntimeAttributes>
                        </textField>
                        <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder=" Password" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="lPu-TL-ucd">
                            <rect key="frame" x="25" y="210" width="550" height="30"/>
                            <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
                            <constraints>
                                <constraint firstAttribute="height" constant="30" id="VeQ-rB-Q84"/>
                            </constraints>
                            <color key="textColor" red="0.20000000300000001" green="0.20000000300000001" blue="0.20000000300000001" alpha="1" colorSpace="calibratedRGB"/>
                            <fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="14"/>
                            <textInputTraits key="textInputTraits" returnKeyType="done" secureTextEntry="YES"/>
                            <userDefinedRuntimeAttributes>
                                <userDefinedRuntimeAttribute type="color" keyPath="layer.borderColor">
                                    <color key="value" red="0.50196081400000003" green="0.0" blue="0.25098040700000002" alpha="1" colorSpace="calibratedRGB"/>
                                </userDefinedRuntimeAttribute>
                            </userDefinedRuntimeAttributes>
                        </textField>
                        <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="2MV-WE-Bs2" customClass="OrangeButton" customModule="FoodOrderingSystem" customModuleProvider="target">
                            <rect key="frame" x="25" y="270" width="550" height="30"/>
                            <constraints>
                                <constraint firstAttribute="height" constant="30" id="xiF-CI-nfC"/>
                            </constraints>
                            <fontDescription key="fontDescription" name="HelveticaNeue-Light" family="Helvetica Neue" pointSize="14"/>
                            <state key="normal" title="Log in"/>
                        </button>
                        <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="OtP-9H-4mM">
                            <rect key="frame" x="231" y="330" width="139" height="30"/>
                            <constraints>
                                <constraint firstAttribute="height" constant="30" id="MCF-6J-2Wo"/>
                                <constraint firstAttribute="width" constant="139" id="lGC-eu-Fff"/>
                            </constraints>
                            <fontDescription key="fontDescription" name="HelveticaNeue-Light" family="Helvetica Neue" pointSize="12"/>
                            <state key="normal" title="Forget your password?">
                                <color key="titleColor" red="0.098039217289999994" green="0.098039217289999994" blue="0.098039217289999994" alpha="1" colorSpace="calibratedRGB"/>
                            </state>
                            <connections>
                                <action selector="forgetPassword:" destination="eG8-k9-KdS" eventType="touchUpInside" id="JjN-Ha-BSt"/>
                            </connections>
                        </button>
                        <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Don't have an account?" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="hXz-jW-DQb">
                            <rect key="frame" x="226" y="470" width="149" height="21"/>
                            <constraints>
                                <constraint firstAttribute="height" constant="21" id="bme-uT-Vuq"/>
                                <constraint firstAttribute="width" constant="149" id="zL1-0o-xBr"/>
                            </constraints>
                            <fontDescription key="fontDescription" name="HelveticaNeue-Light" family="Helvetica Neue" pointSize="14"/>
                            <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
                            <nil key="highlightedColor"/>
                        </label>
                        <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="zVp-1c-Cs5">
                            <rect key="frame" x="25" y="494" width="550" height="30"/>
                            <constraints>
                                <constraint firstAttribute="height" constant="30" id="tab-om-NF2"/>
                            </constraints>
                            <fontDescription key="fontDescription" name="HelveticaNeue-Light" family="Helvetica Neue" pointSize="14"/>
                            <state key="normal" title="Sign up for Free">
                                <color key="titleColor" red="0.29803922770000002" green="0.29803922770000002" blue="0.29803922770000002" alpha="1" colorSpace="calibratedRGB"/>
                            </state>
                            <connections>
                                <action selector="signUp:" destination="eG8-k9-KdS" eventType="touchUpInside" id="Im0-lc-00P"/>
                            </connections>
                        </button>
                    </subviews>
                    <color key="backgroundColor" red="0.95724826388888884" green="0.95724826388888884" blue="0.95724826388888884" alpha="1" colorSpace="calibratedRGB"/>
                    <constraints>
                        <constraint firstItem="OtP-9H-4mM" firstAttribute="centerX" secondItem="2MV-WE-Bs2" secondAttribute="centerX" id="2jV-SB-vpS"/>
                        <constraint firstItem="OtP-9H-4mM" firstAttribute="top" secondItem="2MV-WE-Bs2" secondAttribute="bottom" constant="30" id="3KJ-ny-dn4"/>
                        <constraint firstItem="2MV-WE-Bs2" firstAttribute="top" secondItem="lPu-TL-ucd" secondAttribute="bottom" constant="30" id="3cC-Wo-6CN"/>
                        <constraint firstItem="dO5-c4-J8f" firstAttribute="top" secondItem="Klu-9Y-Iay" secondAttribute="bottom" constant="29" id="6Ei-ke-PbQ"/>
                        <constraint firstItem="zVp-1c-Cs5" firstAttribute="trailing" secondItem="2MV-WE-Bs2" secondAttribute="trailing" id="6KE-cL-GR6"/>
                        <constraint firstItem="M8b-aM-Sop" firstAttribute="top" secondItem="Eda-3z-eWo" secondAttribute="topMargin" constant="-2" id="8TG-AL-dEH"/>
                        <constraint firstItem="lPu-TL-ucd" firstAttribute="top" secondItem="dO5-c4-J8f" secondAttribute="bottom" constant="20" id="AG8-UM-bmV"/>
                        <constraint firstItem="dO5-c4-J8f" firstAttribute="leading" secondItem="lPu-TL-ucd" secondAttribute="leading" id="Amo-0a-jqO"/>
                        <constraint firstItem="dOD-R1-W9P" firstAttribute="top" secondItem="zVp-1c-Cs5" secondAttribute="bottom" constant="76" id="CEI-rG-rql"/>
                        <constraint firstItem="Q8d-5R-XXC" firstAttribute="top" secondItem="Eda-3z-eWo" secondAttribute="top" id="FRK-DD-0xV"/>
                        <constraint firstItem="dO5-c4-J8f" firstAttribute="leading" secondItem="Eda-3z-eWo" secondAttribute="leadingMargin" constant="5" id="Kj5-EA-qwU"/>
                        <constraint firstAttribute="trailing" secondItem="Q8d-5R-XXC" secondAttribute="trailing" id="LTl-Gd-Okj"/>
                        <constraint firstItem="Q8d-5R-XXC" firstAttribute="centerY" secondItem="M8b-aM-Sop" secondAttribute="centerY" id="Nah-5Y-7Yi"/>
                        <constraint firstItem="2MV-WE-Bs2" firstAttribute="leading" secondItem="lPu-TL-ucd" secondAttribute="leading" id="WER-9x-yHy"/>
                        <constraint firstItem="Q8d-5R-XXC" firstAttribute="top" secondItem="Eda-3z-eWo" secondAttribute="topMargin" id="WVg-yo-HkE"/>
                        <constraint firstItem="M8b-aM-Sop" firstAttribute="top" secondItem="Eda-3z-eWo" secondAttribute="top" constant="-2" id="YVc-qE-aC4"/>
                        <constraint firstItem="M8b-aM-Sop" firstAttribute="leading" secondItem="Eda-3z-eWo" secondAttribute="leadingMargin" id="d7b-Ds-fSF"/>
                        <constraint firstItem="Q8d-5R-XXC" firstAttribute="top" secondItem="Eda-3z-eWo" secondAttribute="top" id="dCJ-xG-kGX"/>
                        <constraint firstItem="Wk8-BF-NOh" firstAttribute="top" secondItem="Q8d-5R-XXC" secondAttribute="bottom" constant="75" id="dKH-of-AfK"/>
                        <constraint firstItem="dO5-c4-J8f" firstAttribute="trailing" secondItem="lPu-TL-ucd" secondAttribute="trailing" id="g6z-vh-ehw"/>
                        <constraint firstItem="zVp-1c-Cs5" firstAttribute="top" secondItem="hXz-jW-DQb" secondAttribute="bottom" constant="3" id="l1u-as-xib"/>
                        <constraint firstItem="zVp-1c-Cs5" firstAttribute="centerX" secondItem="hXz-jW-DQb" secondAttribute="centerX" id="nUV-ws-q7n"/>
                        <constraint firstItem="Klu-9Y-Iay" firstAttribute="centerX" secondItem="dO5-c4-J8f" secondAttribute="centerX" id="oXs-l4-hIi"/>
                        <constraint firstItem="Q8d-5R-XXC" firstAttribute="leading" secondItem="Eda-3z-eWo" secondAttribute="leading" id="ptd-HQ-cR4"/>
                        <constraint firstItem="Q8d-5R-XXC" firstAttribute="top" secondItem="Eda-3z-eWo" secondAttribute="top" id="qRR-qq-w6d"/>
                        <constraint firstItem="2MV-WE-Bs2" firstAttribute="leading" secondItem="zVp-1c-Cs5" secondAttribute="leading" id="rG3-iV-SaP"/>
                        <constraint firstItem="2MV-WE-Bs2" firstAttribute="trailing" secondItem="lPu-TL-ucd" secondAttribute="trailing" id="rYi-Jc-oDy"/>
                        <constraint firstItem="Q8d-5R-XXC" firstAttribute="top" secondItem="Eda-3z-eWo" secondAttribute="top" id="sng-xu-kmb"/>
                        <constraint firstItem="Wk8-BF-NOh" firstAttribute="centerX" secondItem="Klu-9Y-Iay" secondAttribute="centerX" id="tHG-Iq-Oou"/>
                        <constraint firstItem="dOD-R1-W9P" firstAttribute="top" secondItem="M8b-aM-Sop" secondAttribute="bottom" constant="572" id="uYa-VE-fbU"/>
                        <constraint firstItem="Q8d-5R-XXC" firstAttribute="centerX" secondItem="Wk8-BF-NOh" secondAttribute="centerX" id="xLz-Tc-bG8"/>
                        <constraint firstItem="Klu-9Y-Iay" firstAttribute="top" secondItem="Wk8-BF-NOh" secondAttribute="bottom" constant="9" id="zp0-cu-ebh"/>
                    </constraints>
                </view>
                <connections>
                    <outlet property="account" destination="dO5-c4-J8f" id="eOY-3g-5EW"/>
                    <outlet property="btnForgetPassword" destination="OtP-9H-4mM" id="lR6-wl-scD"/>
                    <outlet property="btnSignUp" destination="zVp-1c-Cs5" id="PwV-Wf-yxg"/>
                    <outlet property="password" destination="lPu-TL-ucd" id="jSl-EQ-PSh"/>
                </connections>
            </viewController>
            <placeholder placeholderIdentifier="IBFirstResponder" id="32f-Qd-Kpv" userLabel="First Responder" sceneMemberID="firstResponder"/>
        </objects>
        <point key="canvasLocation" x="1031" y="1230"/>
    </scene>
</scenes>

enter image description here

约束我已经尝试过

enter image description here

1 个答案:

答案 0 :(得分:0)

不要偏好保证金。顶级约束是项目视图(不是顶部布局指南)。enter image description here