Skip to content

Commit

Permalink
Add collection view sample
Browse files Browse the repository at this point in the history
  • Loading branch information
andreamazz committed Mar 4, 2016
1 parent 712c10f commit d99ff77
Show file tree
Hide file tree
Showing 5 changed files with 147 additions and 2 deletions.
4 changes: 2 additions & 2 deletions AMScrollingNavbar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.4;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -245,7 +245,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.4;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down
10 changes: 10 additions & 0 deletions Demo/ScrollingNavbarDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

/* Begin PBXBuildFile section */
5735C31E37D9A69C10E478E3 /* Pods_ScrollingNavbarDemoTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 16AAA5B02FFC5555D34B6CC3 /* Pods_ScrollingNavbarDemoTests.framework */; };
652AA8411C80460400FDC96F /* CollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652AA8401C80460400FDC96F /* CollectionViewCell.swift */; };
652AA8431C80468A00FDC96F /* CollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652AA8421C80468A00FDC96F /* CollectionViewController.swift */; };
652BE2D41B62805C00DE75C7 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652BE2D31B62805C00DE75C7 /* AppDelegate.swift */; };
652BE2D61B62805C00DE75C7 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652BE2D51B62805C00DE75C7 /* ViewController.swift */; };
652BE2D91B62805C00DE75C7 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 652BE2D71B62805C00DE75C7 /* Main.storyboard */; };
Expand All @@ -33,6 +35,8 @@
/* Begin PBXFileReference section */
16AAA5B02FFC5555D34B6CC3 /* Pods_ScrollingNavbarDemoTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ScrollingNavbarDemoTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
3E2071594B942BCA37776284 /* Pods-ScrollingNavbarDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ScrollingNavbarDemo.release.xcconfig"; path = "Pods/Target Support Files/Pods-ScrollingNavbarDemo/Pods-ScrollingNavbarDemo.release.xcconfig"; sourceTree = "<group>"; };
652AA8401C80460400FDC96F /* CollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollectionViewCell.swift; sourceTree = "<group>"; };
652AA8421C80468A00FDC96F /* CollectionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollectionViewController.swift; sourceTree = "<group>"; };
652BE2CE1B62805C00DE75C7 /* ScrollingNavbarDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ScrollingNavbarDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
652BE2D21B62805C00DE75C7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
652BE2D31B62805C00DE75C7 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -144,6 +148,7 @@
658FA1711B836D9C00EB32A4 /* ScrollViewController.swift */,
658FA1771B837C6100EB32A4 /* TableViewController.swift */,
658FA1791B8386EB00EB32A4 /* WebViewController.swift */,
652AA8421C80468A00FDC96F /* CollectionViewController.swift */,
);
path = ViewControllers;
sourceTree = "<group>";
Expand All @@ -154,6 +159,7 @@
652BE2D71B62805C00DE75C7 /* Main.storyboard */,
652BE2DA1B62805C00DE75C7 /* Images.xcassets */,
652BE2DC1B62805C00DE75C7 /* LaunchScreen.xib */,
652AA8401C80460400FDC96F /* CollectionViewCell.swift */,
);
name = Resources;
sourceTree = "<group>";
Expand Down Expand Up @@ -371,7 +377,9 @@
files = (
652BE2D61B62805C00DE75C7 /* ViewController.swift in Sources */,
658FA1721B836D9C00EB32A4 /* ScrollViewController.swift in Sources */,
652AA8411C80460400FDC96F /* CollectionViewCell.swift in Sources */,
652BE2D41B62805C00DE75C7 /* AppDelegate.swift in Sources */,
652AA8431C80468A00FDC96F /* CollectionViewController.swift in Sources */,
658FA17A1B8386EB00EB32A4 /* WebViewController.swift in Sources */,
658FA1781B837C6100EB32A4 /* TableViewController.swift in Sources */,
);
Expand Down Expand Up @@ -503,6 +511,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = ScrollingNavbarDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "it.fancypixel.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -516,6 +525,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = ScrollingNavbarDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "it.fancypixel.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
95 changes: 95 additions & 0 deletions Demo/ScrollingNavbarDemo/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,32 @@
<segue destination="Q5s-G0-ypn" kind="show" id="oRv-MW-DeK"/>
</connections>
</tableViewCell>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" rowHeight="100" id="X5t-MF-ozU">
<rect key="frame" x="0.0" y="364" width="600" height="100"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="X5t-MF-ozU" id="MT5-EC-9UL">
<rect key="frame" x="0.0" y="0.0" width="600" height="99.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="CollectionView" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="lfV-fX-VJ4">
<rect key="frame" x="8" y="8" width="584" height="83.5"/>
<color key="backgroundColor" white="0.97999999999999998" alpha="1" colorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" white="0.5" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="lfV-fX-VJ4" firstAttribute="trailing" secondItem="MT5-EC-9UL" secondAttribute="trailingMargin" id="dli-0c-Z9b"/>
<constraint firstItem="lfV-fX-VJ4" firstAttribute="leading" secondItem="MT5-EC-9UL" secondAttribute="leadingMargin" id="epC-JP-dhG"/>
<constraint firstItem="lfV-fX-VJ4" firstAttribute="bottom" secondItem="MT5-EC-9UL" secondAttribute="bottomMargin" id="nFy-VG-yqz"/>
<constraint firstItem="lfV-fX-VJ4" firstAttribute="top" secondItem="MT5-EC-9UL" secondAttribute="topMargin" id="t4d-7N-FN5"/>
</constraints>
</tableViewCellContentView>
<connections>
<segue destination="vrT-AV-HzV" kind="show" id="97m-9N-yGa"/>
</connections>
</tableViewCell>
</cells>
</tableViewSection>
</sections>
Expand All @@ -162,6 +188,75 @@
</objects>
<point key="canvasLocation" x="1220.625" y="373.94366197183098"/>
</scene>
<!--Collection View Controller-->
<scene sceneID="0FI-p5-L1F">
<objects>
<viewController id="vrT-AV-HzV" customClass="CollectionViewController" customModule="ScrollingNavbarDemo" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="70T-8P-hY3"/>
<viewControllerLayoutGuide type="bottom" id="viV-Z3-Q3V"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="VMv-o8-2YB">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="U6b-Kw-4W2">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="quV-aL-Muw">
<size key="itemSize" width="120" height="120"/>
<size key="headerReferenceSize" width="0.0" height="0.0"/>
<size key="footerReferenceSize" width="0.0" height="0.0"/>
<inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
</collectionViewFlowLayout>
<cells>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="CollectionViewCell" id="lbK-Hc-J26" customClass="CollectionViewCell" customModule="ScrollingNavbarDemo" customModuleProvider="target">
<rect key="frame" x="0.0" y="64" width="120" height="120"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="120" height="120"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="eSE-Ii-0ph">
<rect key="frame" x="39" y="49" width="42" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
<constraints>
<constraint firstItem="eSE-Ii-0ph" firstAttribute="centerX" secondItem="lbK-Hc-J26" secondAttribute="centerX" id="lWy-Hg-phi"/>
<constraint firstItem="eSE-Ii-0ph" firstAttribute="centerY" secondItem="lbK-Hc-J26" secondAttribute="centerY" id="oTB-dT-ARu"/>
</constraints>
<connections>
<outlet property="label" destination="eSE-Ii-0ph" id="lTx-CL-TPU"/>
</connections>
</collectionViewCell>
</cells>
<connections>
<outlet property="dataSource" destination="vrT-AV-HzV" id="5Io-fA-Qmg"/>
<outlet property="delegate" destination="vrT-AV-HzV" id="qCh-7Z-sAy"/>
</connections>
</collectionView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="viV-Z3-Q3V" firstAttribute="top" secondItem="U6b-Kw-4W2" secondAttribute="bottom" id="IFP-1e-9XG"/>
<constraint firstAttribute="trailing" secondItem="U6b-Kw-4W2" secondAttribute="trailing" id="NK7-RI-Sqp"/>
<constraint firstItem="U6b-Kw-4W2" firstAttribute="top" secondItem="VMv-o8-2YB" secondAttribute="top" id="Qh5-JF-Zld"/>
<constraint firstItem="U6b-Kw-4W2" firstAttribute="leading" secondItem="VMv-o8-2YB" secondAttribute="leading" id="v5I-gz-rEG"/>
</constraints>
</view>
<connections>
<outlet property="collectionView" destination="U6b-Kw-4W2" id="DCC-dr-Bts"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Q2b-cr-qio" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1220" y="1182"/>
</scene>
<!--Table View Controller-->
<scene sceneID="BJq-ZJ-j0e">
<objects>
Expand Down
5 changes: 5 additions & 0 deletions Demo/ScrollingNavbarDemo/CollectionViewCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import UIKit

class CollectionViewCell: UICollectionViewCell {
@IBOutlet var label: UILabel!
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import UIKit
import AMScrollingNavbar

class CollectionViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate {

@IBOutlet var collectionView: UICollectionView!

override func viewDidLoad() {
super.viewDidLoad()

title = "CollectionView"
navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .Add, target: nil, action: nil)
navigationController?.navigationBar.barTintColor = UIColor(red:0.91, green:0.3, blue:0.24, alpha:1)
}

// Enable the navbar scrolling
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)

if let navigationController = self.navigationController as? ScrollingNavigationController {
navigationController.followScrollView(collectionView, delay: 50.0)
}
}

// MARK: - Collection view data source

func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 100
}

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
return collectionView.dequeueReusableCellWithReuseIdentifier("CollectionViewCell", forIndexPath: indexPath)
}

}

0 comments on commit d99ff77

Please sign in to comment.