Skip to content

Commit

Permalink
Compatible with swift 4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminPrieur committed Jun 6, 2019
1 parent 5b7781f commit 4f0a958
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 261 deletions.
236 changes: 27 additions & 209 deletions Example/IOStickyHeader.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildSystemType</key>
<string>Original</string>
<key>PreviewsEnabled</key>
<false/>
</dict>
</plist>
30 changes: 2 additions & 28 deletions Example/IOStickyHeader/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
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:.
}


}

2 changes: 1 addition & 1 deletion Example/IOStickyHeader/IOGrowVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class IOGrowVC: UIViewController, UICollectionViewDataSource, UICollectionViewDe
self.collectionView.collectionViewLayout = layout
}

self.collectionView.scrollIndicatorInsets = UIEdgeInsetsMake(0, 0, 0, 0)
self.collectionView.scrollIndicatorInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)

self.collectionView.register(self.headerNib, forSupplementaryViewOfKind: IOStickyHeaderParallaxHeader, withReuseIdentifier: "header")
}
Expand Down
4 changes: 2 additions & 2 deletions Example/IOStickyHeader/IOParallaxVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class IOParallaxVC: UIViewController, UICollectionViewDataSource, UICollectionVi
self.collectionView.collectionViewLayout = layout
}

self.collectionView.scrollIndicatorInsets = UIEdgeInsetsMake(0, 0, 0, 0)
self.collectionView.scrollIndicatorInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)

self.collectionView.register(self.headerNib, forSupplementaryViewOfKind: IOStickyHeaderParallaxHeader, withReuseIdentifier: "header")
}
Expand Down Expand Up @@ -93,7 +93,7 @@ class IOParallaxVC: UIViewController, UICollectionViewDataSource, UICollectionVi

func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
switch kind {
case UICollectionElementKindSectionHeader:
case UICollectionView.elementKindSectionHeader:
let cell = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeader", for: indexPath) as! IOSectionHeader
return cell
case IOStickyHeaderParallaxHeader:
Expand Down
10 changes: 8 additions & 2 deletions Example/IOStickyHeader/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<string>1.0.0</string>
<key>LSApplicationCategoryType</key>
<string></string>
<key>NSPrincipalClass</key>
<string></string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
</dict>
</plist>
2 changes: 0 additions & 2 deletions Example/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@ end

target 'IOStickyHeader_Tests' do
pod "IOStickyHeader", :path => "../"


end
10 changes: 5 additions & 5 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
PODS:
- IOStickyHeader (1.0.0)
- IOStickyHeader (1.0.2)

DEPENDENCIES:
- IOStickyHeader (from `../`)

EXTERNAL SOURCES:
IOStickyHeader:
:path: ../
:path: "../"

SPEC CHECKSUMS:
IOStickyHeader: 9aef3014a0fc1ed4cbe702d7a0b574e64516f576
IOStickyHeader: 9371261daf8a55591207834261f946322aee6148

PODFILE CHECKSUM: 98c07bf9f34f0cf1d9ecb9d7de1472459ceca4e2
PODFILE CHECKSUM: b88f7f649d7e9eb6526411bc22b15d354f8dcad1

COCOAPODS: 1.1.0.rc.2
COCOAPODS: 1.7.1
12 changes: 4 additions & 8 deletions IOStickyHeader.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,21 @@

Pod::Spec.new do |s|
s.name = "IOStickyHeader"
s.version = "1.0.1"
s.version = "1.0.4"
s.summary = "Parallax and Sticky header done right using UICollectionViewLayout"
s.description = <<-DESC
UICollectionView are flexible and you can use supplementary views to
anything you wanted.
DESC
s.homepage = "https://github.com/BenjaminPrieur/IOStickyHeader.git"
# s.screenshots = "www.example.com/screenshots_1", "www.example.com/screenshots_2"
s.license = 'MIT'
s.author = { "Benjamin Prieur" => "benjamin@prieur.org" }
s.source = { :git => "https://github.com/BenjaminPrieur/IOStickyHeader.git", :tag => s.version.to_s }
# s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'

s.pod_target_xcconfig = {
'SWIFT_VERSION' => '3.0'
}
s.swift_version = '4.2'

s.platform = :ios, '9.0'
s.ios.deployment_target = '9.0'
s.requires_arc = true

s.source_files = 'Sources/**/*'
s.source_files = 'Sources/**/*.{swift}'
end
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ func collectionView(collectionView: UICollectionView, viewForSupplementaryElemen

## Requirements

- Xcode 8
- Swift 3.0
- Swift 4.2
- iOS 9

## Installation
Expand Down
4 changes: 2 additions & 2 deletions Sources/IOStickyHeaderFlowLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ open class IOStickyHeaderFlowLayout: UICollectionViewFlowLayout {
attributes.frame = frame

let indexPath = attributes.indexPath
if attributes.representedElementKind == UICollectionElementKindSectionHeader {
if attributes.representedElementKind == UICollectionView.elementKindSectionHeader {
headers.setObject(attributes, forKey: (indexPath as NSIndexPath).section as NSCopying)
} else {
let currentAttribute = lastCells.object(forKey: (indexPath as IndexPath).section)
Expand Down Expand Up @@ -131,7 +131,7 @@ open class IOStickyHeaderFlowLayout: UICollectionViewFlowLayout {

var header = headers[indexPAthKey]
if header == nil {
header = self.layoutAttributesForSupplementaryView(ofKind: UICollectionElementKindSectionHeader, at: IndexPath(item: 0, section: (indexPath as NSIndexPath).section))
header = self.layoutAttributesForSupplementaryView(ofKind: UICollectionView.elementKindSectionHeader, at: IndexPath(item: 0, section: (indexPath as NSIndexPath).section))
if let header:UICollectionViewLayoutAttributes = header as? UICollectionViewLayoutAttributes {
allItems.append(header)
}
Expand Down

0 comments on commit 4f0a958

Please sign in to comment.