Layout subviews
This commit is contained in:
parent
a000861fbc
commit
d0070352cc
|
|
@ -2,6 +2,7 @@
|
|||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8121.20" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8101.16"/>
|
||||
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--View Controller-->
|
||||
|
|
@ -15,11 +16,26 @@
|
|||
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="myb-yU-Jdq" customClass="GMStepper" customModule="GMStepper" customModuleProvider="target">
|
||||
<rect key="frame" x="20" y="20" width="284" height="44"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="284" id="RLe-7a-S9I"/>
|
||||
<constraint firstAttribute="height" constant="44" id="bMh-qb-O1H"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="leadingMargin" secondItem="myb-yU-Jdq" secondAttribute="leading" id="NuJ-b9-mHR"/>
|
||||
<constraint firstItem="myb-yU-Jdq" firstAttribute="top" secondItem="y3c-jy-aDJ" secondAttribute="bottom" id="xo4-e0-e0r"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="340" y="387"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
</document>
|
||||
|
|
|
|||
|
|
@ -25,8 +25,31 @@ class GMStepper: UIView {
|
|||
leftButton.addTarget(self, action: "leftButtonTapped:", forControlEvents: .TouchDown)
|
||||
rightButton.addTarget(self, action: "rightButtonTapped:", forControlEvents: .TouchDown)
|
||||
|
||||
label.textAlignment = .Center
|
||||
|
||||
addSubview(leftButton)
|
||||
addSubview(rightButton)
|
||||
addSubview(label)
|
||||
}
|
||||
|
||||
override func layoutSubviews() {
|
||||
let buttonSize = Int(frame.size.height)
|
||||
let labelWidth = Int(frame.size.width) - 2 * buttonSize
|
||||
|
||||
let leftButtonFrame = CGRect(x: 0, y: 0, width: buttonSize, height: buttonSize)
|
||||
let labelFrame = CGRect(x: buttonSize, y: 0, width: labelWidth, height: buttonSize)
|
||||
let rightButtonFrame = CGRect(x: buttonSize + labelWidth, y: 0, width: buttonSize, height: buttonSize)
|
||||
|
||||
leftButton.frame = leftButtonFrame
|
||||
label.frame = labelFrame
|
||||
rightButton.frame = rightButtonFrame
|
||||
}
|
||||
|
||||
func leftButtonTapped(button: UIButton) {
|
||||
|
||||
}
|
||||
|
||||
func rightButtonTapped(button: UIButton) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue