我在 iOS 中使用 Visual Designer 制作 View Controller 初始屏幕,但图像没有出现在中心
I am using the Visual Designer in iOS for a View Controller splash screen but the image does not appear in the center
设计师展示的内容如下:
由于可能不清楚我将在下面添加XML:
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16096" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16086"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="center" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" misplaced="YES" axis="vertical" distribution="equalCentering" alignment="center" spacing="20" translatesAutoresizingMaskIntoConstraints="NO" id="Zbh-CC-wDS">
<rect key="frame" x="107" y="294" width="128" height="136"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="splash_image.png" translatesAutoresizingMaskIntoConstraints="NO" id="znN-uk-H0B">
<rect key="frame" x="0.0" y="0.0" width="128" height="80"/>
<constraints>
<constraint firstAttribute="height" constant="80" id="A2X-j1-ymP"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="ABC" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="EcF-nC-k2o" colorLabel="IBBuiltInLabel-Gray">
<rect key="frame" x="34.5" y="100" width="59" height="36"/>
<fontDescription key="fontDescription" type="system" pointSize="30"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</stackView>
</subviews>
<color key="backgroundColor" red="0.20000000000000001" green="0.20000000000000001" blue="0.20000000000000001" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="Zbh-CC-wDS" firstAttribute="centerX" secondItem="Ze5-6b-2t3" secondAttribute="centerX" id="eih-d4-foy"/>
<constraint firstItem="Zbh-CC-wDS" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="centerY" constant="-60" id="fGG-ZZ-u69"/>
</constraints>
<viewLayoutGuide key="safeArea" id="wza-7a-P1J"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1347.826" y="610.71429999999998"/>
</scene>
</scenes>
<resources>
<image name="splash_image.png" width="128" height="128"/>
</resources>
</document>
居中的方法是否正确?也许通过查看 XML 可以发现问题。
它显示它不在中心,但我不确定为什么。
我是 iOS 的新手,这是我第一次尝试任何东西,所以我不太清楚如何编辑别人创建的布局。
Select Stack View
。然后按command + alt/option + +更新到正确的位置。
最简单的方法是按更新帧按钮
或
首先点击下图中显示的视图控制器上的黄色图标
它将带您进入下一个屏幕..按下警告标志将带您进入此弹出窗口
Select 更新框架 ... 然后按修复错位
设计师展示的内容如下:
由于可能不清楚我将在下面添加XML:
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16096" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16086"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="center" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" misplaced="YES" axis="vertical" distribution="equalCentering" alignment="center" spacing="20" translatesAutoresizingMaskIntoConstraints="NO" id="Zbh-CC-wDS">
<rect key="frame" x="107" y="294" width="128" height="136"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="splash_image.png" translatesAutoresizingMaskIntoConstraints="NO" id="znN-uk-H0B">
<rect key="frame" x="0.0" y="0.0" width="128" height="80"/>
<constraints>
<constraint firstAttribute="height" constant="80" id="A2X-j1-ymP"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="ABC" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="EcF-nC-k2o" colorLabel="IBBuiltInLabel-Gray">
<rect key="frame" x="34.5" y="100" width="59" height="36"/>
<fontDescription key="fontDescription" type="system" pointSize="30"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</stackView>
</subviews>
<color key="backgroundColor" red="0.20000000000000001" green="0.20000000000000001" blue="0.20000000000000001" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="Zbh-CC-wDS" firstAttribute="centerX" secondItem="Ze5-6b-2t3" secondAttribute="centerX" id="eih-d4-foy"/>
<constraint firstItem="Zbh-CC-wDS" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="centerY" constant="-60" id="fGG-ZZ-u69"/>
</constraints>
<viewLayoutGuide key="safeArea" id="wza-7a-P1J"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1347.826" y="610.71429999999998"/>
</scene>
</scenes>
<resources>
<image name="splash_image.png" width="128" height="128"/>
</resources>
</document>
居中的方法是否正确?也许通过查看 XML 可以发现问题。
它显示它不在中心,但我不确定为什么。
我是 iOS 的新手,这是我第一次尝试任何东西,所以我不太清楚如何编辑别人创建的布局。
Select Stack View
。然后按command + alt/option + +更新到正确的位置。
最简单的方法是按更新帧按钮
或
首先点击下图中显示的视图控制器上的黄色图标
它将带您进入下一个屏幕..按下警告标志将带您进入此弹出窗口
Select 更新框架 ... 然后按修复错位