Skip to content

Instantly share code, notes, and snippets.

@mayoff
Created September 10, 2014 15:04
Show Gist options
  • Save mayoff/d9320088ab4025c95e40 to your computer and use it in GitHub Desktop.
Save mayoff/d9320088ab4025c95e40 to your computer and use it in GitHub Desktop.
Storyboard with autolayout constraints for aspect-fit of a subview in a container view, for http://stackoverflow.com/a/25768875/77567
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6245" systemVersion="13E28" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="vXZ-lx-hvc">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6238"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="ufC-wZ-h7g">
<objects>
<viewController id="vXZ-lx-hvc" customClass="ViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="jyV-Pf-zRb"/>
<viewControllerLayoutGuide type="bottom" id="2fi-mo-0CV"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="kh9-bI-dsS">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Bu0-Vn-NWW" userLabel="Top Container">
<rect key="frame" x="0.0" y="20" width="320" height="274"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ccj-6U-TOq" userLabel="Top Fixed">
<rect key="frame" x="0.0" y="97" width="320" height="80"/>
<color key="backgroundColor" red="0.7743756422945951" green="1" blue="0.84614103840741328" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="width" secondItem="ccj-6U-TOq" secondAttribute="height" multiplier="4:1" id="Fzk-E3-Yi4"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" name="selectedTextBackgroundColor" catalog="System" colorSpace="catalog"/>
<constraints>
<constraint firstAttribute="centerY" secondItem="ccj-6U-TOq" secondAttribute="centerY" id="C7Z-mZ-O3F"/>
<constraint firstAttribute="width" secondItem="ccj-6U-TOq" secondAttribute="width" priority="750" id="Qxx-zD-gG3"/>
<constraint firstAttribute="centerX" secondItem="ccj-6U-TOq" secondAttribute="centerX" id="Sgv-83-zCu"/>
<constraint firstAttribute="width" relation="greaterThanOrEqual" secondItem="ccj-6U-TOq" secondAttribute="width" id="Tfk-Wb-vm1"/>
<constraint firstAttribute="height" relation="greaterThanOrEqual" secondItem="ccj-6U-TOq" secondAttribute="height" id="dCD-Gj-ceM"/>
<constraint firstAttribute="height" secondItem="ccj-6U-TOq" secondAttribute="height" priority="750" id="zCK-iT-3h7"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="oDr-sV-87W" userLabel="Bottom Container">
<rect key="frame" x="0.0" y="294" width="320" height="274"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="XyP-yL-Qrj" userLabel="Bottom Fixed">
<rect key="frame" x="126" y="0.0" width="68" height="274"/>
<color key="backgroundColor" red="0.41869353783065227" green="0.78573421556122447" blue="0.31103480678290174" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="width" secondItem="XyP-yL-Qrj" secondAttribute="height" multiplier="1:4" id="jgN-UY-age"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="0.99919813871383667" green="0.79837877270746882" blue="0.94132425558109956" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="XyP-yL-Qrj" firstAttribute="width" secondItem="oDr-sV-87W" secondAttribute="width" priority="750" id="8Ag-aD-4Vm"/>
<constraint firstItem="XyP-yL-Qrj" firstAttribute="height" secondItem="oDr-sV-87W" secondAttribute="height" priority="750" id="C1o-8f-d4N"/>
<constraint firstItem="XyP-yL-Qrj" firstAttribute="width" relation="lessThanOrEqual" secondItem="oDr-sV-87W" secondAttribute="width" id="Mmc-hg-yyn"/>
<constraint firstItem="XyP-yL-Qrj" firstAttribute="height" relation="lessThanOrEqual" secondItem="oDr-sV-87W" secondAttribute="height" id="SvR-cW-nsE"/>
<constraint firstAttribute="centerX" secondItem="XyP-yL-Qrj" secondAttribute="centerX" id="cNG-5z-fBM"/>
<constraint firstAttribute="centerY" secondItem="XyP-yL-Qrj" secondAttribute="centerY" id="of3-X1-PHi"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="2fi-mo-0CV" firstAttribute="top" secondItem="oDr-sV-87W" secondAttribute="bottom" id="8VZ-Ry-apK"/>
<constraint firstAttribute="trailing" secondItem="oDr-sV-87W" secondAttribute="trailing" id="9PA-G3-NcL"/>
<constraint firstItem="oDr-sV-87W" firstAttribute="top" secondItem="Bu0-Vn-NWW" secondAttribute="bottom" id="BCy-kB-avG"/>
<constraint firstItem="Bu0-Vn-NWW" firstAttribute="top" secondItem="jyV-Pf-zRb" secondAttribute="bottom" id="Hg6-Po-05K"/>
<constraint firstItem="Bu0-Vn-NWW" firstAttribute="leading" secondItem="kh9-bI-dsS" secondAttribute="leading" id="PRq-z7-Ugj"/>
<constraint firstAttribute="trailing" secondItem="Bu0-Vn-NWW" secondAttribute="trailing" id="aqe-SH-y7a"/>
<constraint firstItem="oDr-sV-87W" firstAttribute="leading" secondItem="kh9-bI-dsS" secondAttribute="leading" id="guo-VL-Y9e"/>
<constraint firstItem="Bu0-Vn-NWW" firstAttribute="height" secondItem="oDr-sV-87W" secondAttribute="height" id="vXe-Dl-wSQ"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1514" y="1336"/>
</scene>
</scenes>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination" type="retina4"/>
</simulatedMetricsContainer>
</document>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment