Skip to content
This repository has been archived by the owner on May 23, 2022. It is now read-only.

Commit

Permalink
Merge pull request #17 from morizotter/morizotter/set-minimum-height
Browse files Browse the repository at this point in the history
Set minimum height
  • Loading branch information
morizotter committed Jul 28, 2015
2 parents 1831418 + da05bf7 commit c1eb7c6
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
26 changes: 23 additions & 3 deletions Demo/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7706" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7706" systemVersion="14E46" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="Wg8-oe-fU3">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
</dependencies>
<scenes>
<!--View Controller-->
<!--Swifty Drop-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="Example" customModuleProvider="target" sceneMemberID="viewController">
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="Demo" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
Expand Down Expand Up @@ -95,9 +95,29 @@
<constraint firstItem="rvo-DH-qnJ" firstAttribute="bottom" secondItem="8bC-Xf-vdC" secondAttribute="bottomMargin" id="vtn-gf-d8y"/>
</constraints>
</view>
<navigationItem key="navigationItem" title="Swifty Drop" id="WkG-O1-aC5"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="914" y="-492"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="Ii9-bV-B12">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="Wg8-oe-fU3" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="eOY-I5-tV8">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="BYZ-38-t0r" kind="relationship" relationship="rootViewController" id="7al-Ex-9Z5"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="6wb-an-NXB" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="227" y="-492"/>
</scene>
</scenes>
<resources>
Expand Down
5 changes: 5 additions & 0 deletions Demo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()

navigationController?.navigationBarHidden = true
let tapRecognizer = UITapGestureRecognizer(target: self, action: "upAllDrops:")
view.addGestureRecognizer(tapRecognizer)
}
Expand Down Expand Up @@ -76,6 +77,10 @@ class ViewController: UIViewController {
}

func upAllDrops(sender: AnyObject) {
if let hidden = navigationController?.navigationBarHidden {
navigationController?.setNavigationBarHidden(!hidden, animated: true)
}

Drop.upAll()
}

Expand Down
7 changes: 5 additions & 2 deletions SwiftyDrop/Drop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public final class Drop: UIView {
private var topConstraint: NSLayoutConstraint!
private var heightConstraint: NSLayoutConstraint!
private let statusTopMargin: CGFloat = 10.0
private let statusBottomMargin: CGFloat = 15.0
private let statusBottomMargin: CGFloat = 10.0
private var minimumHeight: CGFloat { return Drop.statusBarHeight() + 44.0 }
private var upTimer: NSTimer?
private var startTop: CGFloat?

Expand Down Expand Up @@ -104,7 +105,9 @@ public final class Drop: UIView {
}

private func updateHeight() {
heightConstraint.constant = self.statusLabel.frame.size.height + Drop.statusBarHeight() + statusTopMargin + statusBottomMargin
let calculatedHeight = self.statusLabel.frame.size.height + Drop.statusBarHeight() + statusTopMargin + statusBottomMargin
println("cal: \(calculatedHeight)")
heightConstraint.constant = calculatedHeight > minimumHeight ? calculatedHeight : minimumHeight
self.layoutIfNeeded()
}
}
Expand Down

0 comments on commit c1eb7c6

Please sign in to comment.