diff --git a/CSStickyHeaderFlowLayout.podspec b/CSStickyHeaderFlowLayout.podspec index 0ff3f67..a6ec95b 100644 --- a/CSStickyHeaderFlowLayout.podspec +++ b/CSStickyHeaderFlowLayout.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "CSStickyHeaderFlowLayout" - s.version = "0.2.11" + s.version = "0.2.12" s.summary = "Parallax and Sticky header done right using UICollectionViewLayout" s.description = <<-DESC UICollectionView are flexible and you can use supplementary views to diff --git a/Project/CSStickyHeaderFlowLayoutDemo.xcodeproj/xcshareddata/xcschemes/CSStickyHeaderFlowLayoutCarthage.xcscheme b/Project/CSStickyHeaderFlowLayoutDemo.xcodeproj/xcshareddata/xcschemes/CSStickyHeaderFlowLayoutCarthage.xcscheme index 543f210..8927e3b 100644 --- a/Project/CSStickyHeaderFlowLayoutDemo.xcodeproj/xcshareddata/xcschemes/CSStickyHeaderFlowLayoutCarthage.xcscheme +++ b/Project/CSStickyHeaderFlowLayoutDemo.xcodeproj/xcshareddata/xcschemes/CSStickyHeaderFlowLayoutCarthage.xcscheme @@ -1,6 +1,6 @@ @@ -29,8 +29,6 @@ shouldUseLaunchSchemeArgsEnv = "YES"> - - - - diff --git a/Project/CSStickyHeaderFlowLayoutDemo.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Project/CSStickyHeaderFlowLayoutDemo.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Project/CSStickyHeaderFlowLayoutDemo.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Project/Pods/Pods.xcodeproj/xcshareddata/xcschemes/CSStickyHeaderFlowLayout.xcscheme b/Project/Pods/Pods.xcodeproj/xcshareddata/xcschemes/CSStickyHeaderFlowLayout.xcscheme index 0c73e58..10ff8e7 100644 --- a/Project/Pods/Pods.xcodeproj/xcshareddata/xcschemes/CSStickyHeaderFlowLayout.xcscheme +++ b/Project/Pods/Pods.xcodeproj/xcshareddata/xcschemes/CSStickyHeaderFlowLayout.xcscheme @@ -1,6 +1,6 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Project/SwiftDemo/SwiftDemo/AppDelegate.swift b/Project/SwiftDemo/SwiftDemo/AppDelegate.swift index e31cb63..dd57121 100644 --- a/Project/SwiftDemo/SwiftDemo/AppDelegate.swift +++ b/Project/SwiftDemo/SwiftDemo/AppDelegate.swift @@ -13,42 +13,17 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - - func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { // Override point for customization after application launch. let stickyHeaderFlowLayout = CSStickyHeaderFlowLayout() let collectionViewController = CollectionViewController(collectionViewLayout: stickyHeaderFlowLayout) - let window = UIWindow(frame: UIScreen.mainScreen().bounds) + let window = UIWindow(frame: UIScreen.main.bounds) window.rootViewController = collectionViewController window.makeKeyAndVisible() self.window = window return true } - - func applicationWillResignActive(application: UIApplication) { - // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. - // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. - } - - func applicationDidEnterBackground(application: UIApplication) { - // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. - // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. - } - - func applicationWillEnterForeground(application: UIApplication) { - // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. - } - - func applicationDidBecomeActive(application: UIApplication) { - // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. - } - - func applicationWillTerminate(application: UIApplication) { - // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. - } - - } diff --git a/Project/SwiftDemo/SwiftDemo/CollectionParallaxHeader.swift b/Project/SwiftDemo/SwiftDemo/CollectionParallaxHeader.swift index 60fc7e9..9b9e7a9 100644 --- a/Project/SwiftDemo/SwiftDemo/CollectionParallaxHeader.swift +++ b/Project/SwiftDemo/SwiftDemo/CollectionParallaxHeader.swift @@ -15,14 +15,14 @@ class CollectionParallaxHeader: UICollectionReusableView { override init(frame: CGRect) { super.init(frame: frame) - self.backgroundColor = UIColor.lightGrayColor() + self.backgroundColor = UIColor.lightGray self.clipsToBounds = true - let bounds = CGRectMake(0, 0, CGRectGetMaxX(frame), CGRectGetMaxY(frame)) + let bounds = CGRect(x: 0, y: 0, width: frame.maxX, height: frame.maxY) let imageView = UIImageView(frame: bounds) - imageView.contentMode = UIViewContentMode.ScaleAspectFill + imageView.contentMode = UIView.ContentMode.scaleAspectFill imageView.image = UIImage(named: "success-baby") self.imageView = imageView self.addSubview(imageView) diff --git a/Project/SwiftDemo/SwiftDemo/CollectionViewCell.swift b/Project/SwiftDemo/SwiftDemo/CollectionViewCell.swift index 220133a..dc76a04 100644 --- a/Project/SwiftDemo/SwiftDemo/CollectionViewCell.swift +++ b/Project/SwiftDemo/SwiftDemo/CollectionViewCell.swift @@ -21,11 +21,11 @@ class CollectionViewCell: UICollectionViewCell { override init(frame: CGRect) { super.init(frame: frame) - self.backgroundColor = UIColor.whiteColor() + self.backgroundColor = UIColor.white - let bounds = CGRectMake(0, 0, CGRectGetMaxX(frame), CGRectGetMaxY(frame)) + let bounds = CGRect(x: 0, y: 0, width: frame.maxX, height: frame.maxY) let label = UILabel(frame: bounds) - label.autoresizingMask = [UIViewAutoresizing.FlexibleHeight, UIViewAutoresizing.FlexibleWidth] + label.autoresizingMask = [UIView.AutoresizingMask.flexibleHeight, UIView.AutoresizingMask.flexibleWidth] self.textLabel = label self.addSubview(label) } diff --git a/Project/SwiftDemo/SwiftDemo/CollectionViewController.swift b/Project/SwiftDemo/SwiftDemo/CollectionViewController.swift index 9ee41f4..0a063ae 100644 --- a/Project/SwiftDemo/SwiftDemo/CollectionViewController.swift +++ b/Project/SwiftDemo/SwiftDemo/CollectionViewController.swift @@ -20,44 +20,45 @@ class CollectionViewController: UICollectionViewController { super.viewDidLoad() self.collectionView?.alwaysBounceVertical = true - self.view.backgroundColor = UIColor.whiteColor() + self.collectionView.backgroundColor = .groupTableViewBackground + self.view.backgroundColor = UIColor.white // Setup Cell - self.collectionView?.registerClass(CollectionViewCell.self, forCellWithReuseIdentifier: "cell") - self.layout?.itemSize = CGSizeMake(self.view.frame.size.width, 44) + self.collectionView?.register(CollectionViewCell.self, forCellWithReuseIdentifier: "cell") + self.layout?.itemSize = CGSize(width: self.view.frame.size.width, height: 44) // Setup Header - self.collectionView?.registerClass(CollectionParallaxHeader.self, forSupplementaryViewOfKind: CSStickyHeaderParallaxHeader, withReuseIdentifier: "parallaxHeader") - self.layout?.parallaxHeaderReferenceSize = CGSizeMake(self.view.frame.size.width, 100) + self.collectionView?.register(CollectionParallaxHeader.self, forSupplementaryViewOfKind: CSStickyHeaderParallaxHeader, withReuseIdentifier: "parallaxHeader") + self.layout?.parallaxHeaderReferenceSize = CGSize(width: self.view.frame.size.width, height: 100) // Setup Section Header - self.collectionView?.registerClass(CollectionViewSectionHeader.self, forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, withReuseIdentifier: "sectionHeader") - self.layout?.headerReferenceSize = CGSizeMake(320, 40) + self.collectionView?.register(CollectionViewSectionHeader.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: "sectionHeader") + self.layout?.headerReferenceSize = CGSize(width: 320, height: 40) } // Cells - override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return self.items.count } - override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { + override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { - let cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as! CollectionViewCell + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! CollectionViewCell cell.text = self.items[indexPath.row] return cell } // Parallax Header - override func collectionView(collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: NSIndexPath) -> UICollectionReusableView { + override func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { if kind == CSStickyHeaderParallaxHeader { - let view = collectionView.dequeueReusableSupplementaryViewOfKind(kind, withReuseIdentifier: "parallaxHeader", forIndexPath: indexPath) + let view = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "parallaxHeader", for: indexPath) return view - } else if kind == UICollectionElementKindSectionHeader { - let view = collectionView.dequeueReusableSupplementaryViewOfKind(kind, withReuseIdentifier: "sectionHeader", forIndexPath: indexPath) - view.backgroundColor = UIColor.lightGrayColor() + } else if kind == UICollectionView.elementKindSectionHeader { + let view = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeader", for: indexPath) + view.backgroundColor = UIColor.lightGray return view } diff --git a/Project/SwiftDemo/SwiftDemo/CollectionViewSectionHeader.swift b/Project/SwiftDemo/SwiftDemo/CollectionViewSectionHeader.swift index d160ed8..d91febf 100644 --- a/Project/SwiftDemo/SwiftDemo/CollectionViewSectionHeader.swift +++ b/Project/SwiftDemo/SwiftDemo/CollectionViewSectionHeader.swift @@ -24,6 +24,6 @@ class CollectionViewSectionHeader: UICollectionReusableView { func commonInit() { self.addSubview(label) label.frame = self.bounds - label.text = UICollectionElementKindSectionHeader + label.text = UICollectionView.elementKindSectionHeader } } diff --git a/Project/SwiftDemo/SwiftDemo/Info.plist b/Project/SwiftDemo/SwiftDemo/Info.plist index 83351f2..d39a4da 100644 --- a/Project/SwiftDemo/SwiftDemo/Info.plist +++ b/Project/SwiftDemo/SwiftDemo/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - com.jamztang.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/Project/SwiftDemo/SwiftDemoTests/Info.plist b/Project/SwiftDemo/SwiftDemoTests/Info.plist index 609467f..ba72822 100644 --- a/Project/SwiftDemo/SwiftDemoTests/Info.plist +++ b/Project/SwiftDemo/SwiftDemoTests/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - com.jamztang.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/README.md b/README.md index 1ed307c..79dc42e 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,8 @@ Run the project examples and it'll shows you exactly how you achieve different e ![](http://f.cl.ly/items/313D2n3R0H0e0x090B3X/different-header.jpeg) ## Updates +- 0.2.12: Add Swift 5 Demo + - 0.2.11: Add support for carthage. - 0.2.10: Fixed issue because attributes were not copied and datasource might have been niled