Skip to content

Commit 570d092

Browse files
committed
Update layout constraints
1 parent f4c7773 commit 570d092

File tree

5 files changed

+22
-18
lines changed

5 files changed

+22
-18
lines changed

DateTimePickerDemo/DateTimePickerDemo/ViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ class ViewController: UIViewController, DateTimePickerDelegate {
2323
// picker.todayButtonTitle = "Today"
2424
// picker.is12HourFormat = true
2525
picker.dateFormat = "hh:mm:ss aa dd/MM/YYYY"
26-
picker.isDatePickerOnly = true
26+
picker.isTimePickerOnly = true
2727
picker.includesMonth = true
28-
// picker.includesSecond = true
28+
picker.includesSecond = true
2929
picker.highlightColor = UIColor(red: 255.0/255.0, green: 138.0/255.0, blue: 138.0/255.0, alpha: 1)
3030
picker.doneButtonTitle = "!! DONE DONE !!"
3131
picker.doneBackgroundColor = UIColor(red: 255.0/255.0, green: 138.0/255.0, blue: 138.0/255.0, alpha: 1)

DateTimePickerDemo/Podfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PODS:
2-
- DateTimePicker (2.4.0)
2+
- DateTimePicker (2.5.1)
33

44
DEPENDENCIES:
55
- DateTimePicker (from `../`)
@@ -9,8 +9,8 @@ EXTERNAL SOURCES:
99
:path: "../"
1010

1111
SPEC CHECKSUMS:
12-
DateTimePicker: 778c3d3d1e3b1d4172c46feb0a319e2b31a94879
12+
DateTimePicker: f7d3305252c1d7a67c9cca58ce8592f8396841ca
1313

1414
PODFILE CHECKSUM: a26e66cb94802972f6430185232278dc132b5b0e
1515

16-
COCOAPODS: 1.8.4
16+
COCOAPODS: 1.9.3

Source/DateTimePicker.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ public protocol DateTimePickerDelegate: class {
275275
@IBOutlet private var contentViewHeight: NSLayoutConstraint!
276276
@IBOutlet private var separatorBottomViewWidth: NSLayoutConstraint!
277277
@IBOutlet private var separatorTopViewWidth: NSLayoutConstraint!
278+
@IBOutlet private weak var doneButtonTopSpace: NSLayoutConstraint!
278279

279280
private var modalCloseHandler: (() -> Void)?
280281

@@ -368,7 +369,7 @@ public protocol DateTimePickerDelegate: class {
368369
private func configureView() {
369370

370371
// content view
371-
contentHeight = isDatePickerOnly ? 228 : isTimePickerOnly ? 230 : 330
372+
contentHeight = isDatePickerOnly ? 244 : isTimePickerOnly ? 230 : 330
372373

373374
contentView.layer.shadowColor = UIColor(white: 0, alpha: 0.3).cgColor
374375
contentView.layer.shadowOffset = CGSize(width: 0, height: -2.0)
@@ -432,7 +433,10 @@ public protocol DateTimePickerDelegate: class {
432433
doneButton.layer.masksToBounds = true
433434
doneButton.addTarget(self, action: #selector(DateTimePicker.donePicking(sender:)), for: .touchUpInside)
434435

436+
// hide entire time view in date-only mode
435437
timeView.isHidden = isDatePickerOnly
438+
// extra bottom space for day view
439+
doneButtonTopSpace.constant = isDatePickerOnly ? 16 : 0
436440

437441
// hour table view
438442
hourTableView.rowHeight = 36
@@ -502,9 +506,9 @@ public protocol DateTimePickerDelegate: class {
502506
}
503507

504508
separatorTopView.backgroundColor = darkColor.withAlphaComponent(0.2)
505-
separatorTopView.isHidden = isDatePickerOnly || isTimePickerOnly
509+
separatorTopView.isHidden = isDatePickerOnly
506510
separatorBottomView.backgroundColor = darkColor.withAlphaComponent(0.2)
507-
separatorBottomView.isHidden = isDatePickerOnly || isTimePickerOnly
511+
separatorBottomView.isHidden = isDatePickerOnly
508512

509513
separatorBottomViewWidth.constant = separatorWidth
510514
separatorTopViewWidth.constant = separatorWidth

Source/DateTimePicker.xib

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
1616
<subviews>
1717
<view clipsSubviews="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="q9d-RF-GrX">
18-
<rect key="frame" x="0.0" y="566" width="414" height="330"/>
18+
<rect key="frame" x="0.0" y="550" width="414" height="346"/>
1919
<subviews>
2020
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="gWq-wF-qaT">
2121
<rect key="frame" x="0.0" y="0.0" width="414" height="44"/>
@@ -51,7 +51,7 @@
5151
</constraints>
5252
</view>
5353
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="PGW-1b-76M">
54-
<rect key="frame" x="16" y="266" width="382" height="44"/>
54+
<rect key="frame" x="16" y="282" width="382" height="44"/>
5555
<constraints>
5656
<constraint firstAttribute="height" constant="44" id="H6V-cd-H4J"/>
5757
</constraints>
@@ -71,7 +71,7 @@
7171
<rect key="frame" x="0.0" y="1" width="414" height="100"/>
7272
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
7373
<constraints>
74-
<constraint firstAttribute="height" constant="100" id="l86-YT-nae"/>
74+
<constraint firstAttribute="height" priority="999" constant="100" id="l86-YT-nae"/>
7575
</constraints>
7676
<collectionViewLayout key="collectionViewLayout" id="3VZ-dd-SiT" customClass="StepCollectionViewFlowLayout" customModule="DateTimePicker"/>
7777
</collectionView>
@@ -149,15 +149,15 @@
149149
</subviews>
150150
</stackView>
151151
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="K7h-lq-Fpy">
152-
<rect key="frame" x="77" y="225" width="260" height="1"/>
152+
<rect key="frame" x="77" y="241" width="260" height="1"/>
153153
<color key="backgroundColor" systemColor="opaqueSeparatorColor"/>
154154
<constraints>
155155
<constraint firstAttribute="height" constant="1" id="PeV-BT-4cg"/>
156156
<constraint firstAttribute="width" constant="260" id="c56-bS-553"/>
157157
</constraints>
158158
</view>
159159
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="lVg-4m-JC2">
160-
<rect key="frame" x="77" y="184" width="260" height="1"/>
160+
<rect key="frame" x="77" y="202" width="260" height="1"/>
161161
<color key="backgroundColor" systemColor="opaqueSeparatorColor"/>
162162
<constraints>
163163
<constraint firstAttribute="height" constant="1" id="1mh-5c-7bC"/>
@@ -174,9 +174,9 @@
174174
<constraint firstItem="DNy-kS-2jV" firstAttribute="trailing" secondItem="q9d-RF-GrX" secondAttribute="trailing" id="Vhb-he-JK8"/>
175175
<constraint firstAttribute="trailing" secondItem="PGW-1b-76M" secondAttribute="trailing" constant="16" id="WsY-04-iIj"/>
176176
<constraint firstItem="gWq-wF-qaT" firstAttribute="leading" secondItem="q9d-RF-GrX" secondAttribute="leading" id="a7O-mg-zNA"/>
177-
<constraint firstItem="PGW-1b-76M" firstAttribute="top" secondItem="DNy-kS-2jV" secondAttribute="bottom" id="bm8-Uw-HcX"/>
178-
<constraint firstItem="K7h-lq-Fpy" firstAttribute="top" secondItem="lVg-4m-JC2" secondAttribute="bottom" constant="40" id="c1M-ap-Wkd"/>
179-
<constraint firstAttribute="height" constant="330" id="kg6-af-apQ"/>
177+
<constraint firstItem="PGW-1b-76M" firstAttribute="top" secondItem="DNy-kS-2jV" secondAttribute="bottom" constant="16" id="bm8-Uw-HcX"/>
178+
<constraint firstItem="K7h-lq-Fpy" firstAttribute="top" secondItem="lVg-4m-JC2" secondAttribute="bottom" constant="38" id="c1M-ap-Wkd"/>
179+
<constraint firstAttribute="height" constant="346" id="kg6-af-apQ"/>
180180
<constraint firstItem="K7h-lq-Fpy" firstAttribute="centerX" secondItem="q9d-RF-GrX" secondAttribute="centerX" id="lhq-3U-KHz"/>
181181
<constraint firstItem="gWq-wF-qaT" firstAttribute="top" secondItem="q9d-RF-GrX" secondAttribute="top" id="q10-AX-sWi"/>
182182
<constraint firstItem="PGW-1b-76M" firstAttribute="top" secondItem="K7h-lq-Fpy" secondAttribute="bottom" constant="40" id="r9O-Xl-uni"/>
@@ -203,6 +203,7 @@
203203
<outlet property="dateTitleLabel" destination="kYf-29-KCB" id="mOX-pO-dCc"/>
204204
<outlet property="dayCollectionView" destination="0j6-O2-Yx4" id="Tfm-J4-zVl"/>
205205
<outlet property="doneButton" destination="PGW-1b-76M" id="fLK-tx-ouc"/>
206+
<outlet property="doneButtonTopSpace" destination="bm8-Uw-HcX" id="gw3-uE-KXf"/>
206207
<outlet property="hourTableView" destination="aG3-VH-4YD" id="KIR-g5-Orl"/>
207208
<outlet property="minuteTableView" destination="Y8i-6h-Vwq" id="nyo-PG-1nl"/>
208209
<outlet property="secondTableView" destination="TPi-88-rp3" id="dTJ-S4-NR3"/>

Source/FullDateCollectionViewCell.xib

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,12 @@
4141
</subviews>
4242
<constraints>
4343
<constraint firstItem="gWW-Vs-Nj2" firstAttribute="height" secondItem="gxb-lJ-6rI" secondAttribute="height" multiplier="0.5" id="VWX-E1-P69"/>
44-
<constraint firstAttribute="height" constant="60" id="vsh-f4-r7c"/>
4544
<constraint firstItem="LyH-8K-Gro" firstAttribute="height" secondItem="gxb-lJ-6rI" secondAttribute="height" multiplier="0.5" id="yMh-oh-H44"/>
4645
</constraints>
4746
</stackView>
4847
</subviews>
4948
<constraints>
50-
<constraint firstItem="WnS-uE-DCR" firstAttribute="leading" secondItem="uIy-0h-KKd" secondAttribute="leading" constant="5" id="CIL-gF-GTn"/>
49+
<constraint firstItem="WnS-uE-DCR" firstAttribute="leading" secondItem="uIy-0h-KKd" secondAttribute="leading" priority="999" constant="5" id="CIL-gF-GTn"/>
5150
<constraint firstItem="WnS-uE-DCR" firstAttribute="centerY" secondItem="uIy-0h-KKd" secondAttribute="centerY" id="SRa-BV-TaU"/>
5251
<constraint firstAttribute="trailing" secondItem="WnS-uE-DCR" secondAttribute="trailing" constant="5" id="iR4-MY-xEI"/>
5352
<constraint firstItem="WnS-uE-DCR" firstAttribute="top" relation="greaterThanOrEqual" secondItem="uIy-0h-KKd" secondAttribute="top" id="mtO-Ts-Eah"/>

0 commit comments

Comments
 (0)