Из изображений, которые вы разместили, он выглядит так, как будто вы правильно настроили ограничения.
Примечание: может быть полезно назвать ваши элементы интерфейса, когда они не подключены к @IBOutlet
. Проверка ограничений и просмотр чего-то вроде:
View.width = View.width
может быть довольно запутанным по сравнению с (если я правильно читаю ваши ограничения):
OrangeView.width = GreenView.width
Я попытался воспроизвести ваш макет, и У меня нет проблемы, которую вы испытываете. Попробуйте ... если представления Imagen Español
и Imagen Ingles
остаются на своих местах, сравните мои ограничения с вашими и посмотрите, не найдете ли вы какие-либо различия, вызывающие проблему.
Вот источник раскадровки :
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16096" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="DYH-hb-0xS">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Select Language View Controller-->
<scene sceneID="3Vw-gp-IQV">
<objects>
<viewController id="DYH-hb-0xS" customClass="SelectLanguageViewController" customModule="MiniScratch" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="W6i-IC-bIv">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="pencil.circle" catalog="system" translatesAutoresizingMaskIntoConstraints="NO" id="ugX-ma-vgM">
<rect key="frame" x="150" y="180.5" width="114" height="113"/>
<constraints>
<constraint firstAttribute="width" constant="100" id="TOW-nR-HFA"/>
<constraint firstAttribute="width" secondItem="ugX-ma-vgM" secondAttribute="height" multiplier="1:1" id="dqp-Bi-aaq"/>
<constraint firstAttribute="width" secondItem="ugX-ma-vgM" secondAttribute="height" multiplier="1:1" id="pRb-Mg-k7c"/>
<constraint firstAttribute="width" constant="114" id="uBv-y0-pAP"/>
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="TOW-nR-HFA"/>
<exclude reference="dqp-Bi-aaq"/>
</mask>
</variation>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Le Blanc" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dFl-iU-tdo">
<rect key="frame" x="151.5" y="302" width="111" height="33.5"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="28"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Please select a language" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="BOc-3S-ImB">
<rect key="frame" x="102" y="343.5" width="210.5" height="23"/>
<fontDescription key="fontDescription" type="system" pointSize="19"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<stackView opaque="NO" contentMode="scaleToFill" spacing="29" translatesAutoresizingMaskIntoConstraints="NO" id="tQ1-jP-jlt" userLabel="OrangeGreenStack">
<rect key="frame" x="92.5" y="386.5" width="229" height="150"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="LhZ-T7-3jj" userLabel="GreenView">
<rect key="frame" x="0.0" y="0.0" width="100" height="150"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="fillEqually" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="mfE-ec-mp7" userLabel="SpanishStack">
<rect key="frame" x="10" y="10" width="80" height="130"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="pencil.circle" catalog="system" translatesAutoresizingMaskIntoConstraints="NO" id="hDJ-VM-0H8">
<rect key="frame" x="0.0" y="0.5" width="80" height="60"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Spanish" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="106-nV-uFU">
<rect key="frame" x="0.0" y="69" width="80" height="61"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</stackView>
</subviews>
<color key="backgroundColor" red="0.2048633993" green="0.78171128030000003" blue="0.34992033239999998" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="mfE-ec-mp7" secondAttribute="bottom" constant="10" id="Ap9-Re-UGN"/>
<constraint firstAttribute="trailing" secondItem="mfE-ec-mp7" secondAttribute="trailing" constant="10" id="D8V-cT-vkM"/>
<constraint firstAttribute="height" constant="150" id="MUG-b3-8IY"/>
<constraint firstAttribute="width" constant="100" id="NK3-gz-vqg"/>
<constraint firstItem="mfE-ec-mp7" firstAttribute="top" secondItem="LhZ-T7-3jj" secondAttribute="top" constant="10" id="RXb-2e-fcv"/>
<constraint firstItem="mfE-ec-mp7" firstAttribute="leading" secondItem="LhZ-T7-3jj" secondAttribute="leading" constant="10" id="x7P-dZ-XU3"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Oay-YI-rrw" userLabel="OrangeView">
<rect key="frame" x="129" y="0.0" width="100" height="150"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="fillEqually" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="Fdg-fY-ViJ" userLabel="EnglishStack">
<rect key="frame" x="10" y="10" width="80" height="130"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="pencil.circle" catalog="system" translatesAutoresizingMaskIntoConstraints="NO" id="nTD-5F-pvb">
<rect key="frame" x="0.0" y="0.5" width="80" height="60"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="English" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="iVa-qQ-BKQ">
<rect key="frame" x="0.0" y="69" width="80" height="61"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</stackView>
</subviews>
<color key="backgroundColor" red="0.9999875426" green="0.6251454353" blue="0.0002199066948" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="Fdg-fY-ViJ" secondAttribute="trailing" constant="10" id="OFt-Ds-7ug"/>
<constraint firstItem="Fdg-fY-ViJ" firstAttribute="top" secondItem="Oay-YI-rrw" secondAttribute="top" constant="10" id="afy-NB-rae"/>
<constraint firstItem="Fdg-fY-ViJ" firstAttribute="leading" secondItem="Oay-YI-rrw" secondAttribute="leading" constant="10" id="egU-Sd-RlC"/>
<constraint firstAttribute="height" constant="150" id="xVk-EX-tZW"/>
<constraint firstAttribute="bottom" secondItem="Fdg-fY-ViJ" secondAttribute="bottom" constant="10" id="yVL-mM-9jg"/>
</constraints>
</view>
</subviews>
<constraints>
<constraint firstItem="Oay-YI-rrw" firstAttribute="width" secondItem="LhZ-T7-3jj" secondAttribute="width" id="Cow-kv-pFC"/>
</constraints>
</stackView>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints>
<constraint firstItem="ugX-ma-vgM" firstAttribute="top" secondItem="AjE-1X-LS6" secondAttribute="top" constant="136" id="KLb-5n-W3U"/>
<constraint firstItem="dFl-iU-tdo" firstAttribute="top" secondItem="ugX-ma-vgM" secondAttribute="bottom" constant="8" id="Oub-GU-Clu"/>
<constraint firstItem="tQ1-jP-jlt" firstAttribute="top" secondItem="BOc-3S-ImB" secondAttribute="bottom" constant="20" id="TCb-3H-BSD"/>
<constraint firstItem="ugX-ma-vgM" firstAttribute="centerX" secondItem="W6i-IC-bIv" secondAttribute="centerX" id="VCy-1R-a2z"/>
<constraint firstItem="ugX-ma-vgM" firstAttribute="centerX" secondItem="W6i-IC-bIv" secondAttribute="centerX" id="aus-IV-w9l"/>
<constraint firstItem="BOc-3S-ImB" firstAttribute="top" secondItem="dFl-iU-tdo" secondAttribute="bottom" constant="8" id="mBb-7f-Tv2"/>
<constraint firstItem="dFl-iU-tdo" firstAttribute="centerX" secondItem="W6i-IC-bIv" secondAttribute="centerX" id="re8-ok-hGZ"/>
<constraint firstItem="tQ1-jP-jlt" firstAttribute="centerX" secondItem="W6i-IC-bIv" secondAttribute="centerX" id="xes-5F-gJB"/>
<constraint firstItem="BOc-3S-ImB" firstAttribute="centerX" secondItem="W6i-IC-bIv" secondAttribute="centerX" id="xtm-sW-5Q9"/>
</constraints>
<viewLayoutGuide key="safeArea" id="AjE-1X-LS6"/>
<variation key="default">
<mask key="constraints">
<exclude reference="VCy-1R-a2z"/>
</mask>
</variation>
</view>
<connections>
<outlet property="encabezadoEtiqueta" destination="BOc-3S-ImB" id="0vm-Zq-Ibk"/>
<outlet property="etiquetaEspañol" destination="106-nV-uFU" id="2pC-b9-5vQ"/>
<outlet property="etiquetaIngles" destination="iVa-qQ-BKQ" id="fRg-Ii-ZOt"/>
<outlet property="imagenEspañol" destination="hDJ-VM-0H8" id="uhg-7L-BV2"/>
<outlet property="imagenIngles" destination="nTD-5F-pvb" id="isY-SQ-Rjy"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="KGv-sc-F94" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-504.375" y="1450"/>
</scene>
</scenes>
<resources>
<image name="pencil.circle" catalog="system" width="128" height="121"/>
</resources>
</document>
и вот класс с @IBOutlet
соединениями:
//
// SelectLanguageViewController.swift
// Created by Don Mag on 4/24/20.
//
import UIKit
class SelectLanguageViewController: UIViewController {
@IBOutlet var encabezadoEtiqueta: UILabel!
@IBOutlet var imagenEspañol: UIImageView!
@IBOutlet var imagenIngles: UIImageView!
@IBOutlet var etiquetaEspañol: UILabel!
@IBOutlet var etiquetaIngles: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
}
}