diff --git a/Podfile b/Podfile index dd41de5..7340887 100644 --- a/Podfile +++ b/Podfile @@ -1,18 +1,18 @@ # Uncomment the next line to define a global platform for your project # platform :ios, '9.0' -target 'ZJFlexibleLayout' do +#target 'ZJFlexibleLayout' do # Comment the next line if you're not using Swift and don't want to use dynamic frameworks - use_frameworks! + #use_frameworks! # Pods for ZJFlexibleLayout -end +#end target 'ZJFlexibleLayoutDemo' do # Comment the next line if you're not using Swift and don't want to use dynamic frameworks use_frameworks! - pod 'ZJFlexibleLayout' + pod 'ZJFlexibleLayout', :path => './' # Pods for ZJFlexibleLayoutDemo end diff --git a/Podfile.lock b/Podfile.lock index 79916b9..5fb6fa0 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -2,15 +2,15 @@ PODS: - ZJFlexibleLayout (1.0) DEPENDENCIES: - - ZJFlexibleLayout + - ZJFlexibleLayout (from `./`) -SPEC REPOS: - https://github.com/cocoapods/specs.git: - - ZJFlexibleLayout +EXTERNAL SOURCES: + ZJFlexibleLayout: + :path: "./" SPEC CHECKSUMS: ZJFlexibleLayout: 58094cc7c51113a356f3d80c3e3107af4ef47387 -PODFILE CHECKSUM: 6405007a9fdd917f386c6e0d26335333e9256a16 +PODFILE CHECKSUM: 3bde4c2155ece160a6a96481951b46cbd2b75df6 -COCOAPODS: 1.5.3 +COCOAPODS: 1.8.4 diff --git a/Source/ZJFlexibleLayout.swift b/Source/ZJFlexibleLayout.swift index 1063e2c..6a0508b 100644 --- a/Source/ZJFlexibleLayout.swift +++ b/Source/ZJFlexibleLayout.swift @@ -65,7 +65,7 @@ open class ZJFlexibleLayout: UICollectionViewLayout { let headerH = headerSize.height //拼接header 的layoutAttributes - let headerAttributes = UICollectionViewLayoutAttributes(forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, with: IndexPath(item: 0, section: section)) + let headerAttributes = UICollectionViewLayoutAttributes(forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, with: IndexPath(item: 0, section: section)) headerAttributes.frame = CGRect(x: headerX, y: currentSectionHeaderY, width: headerSize.width, height: headerSize.height) layoutHeaderViewInfo.append(headerAttributes) diff --git a/ZJFlexibleLayout.podspec b/ZJFlexibleLayout.podspec index 9deeda2..dea180d 100644 --- a/ZJFlexibleLayout.podspec +++ b/ZJFlexibleLayout.podspec @@ -16,7 +16,7 @@ Pod::Spec.new do |s| # s.name = "ZJFlexibleLayout" - s.version = "1.0" + s.version = "2.0" s.summary = "An intuitive custom tool of making flexible layout including waterfall flow." # This description is used to generate tags and improve search results. diff --git a/ZJFlexibleLayoutDemo.xcodeproj/project.pbxproj b/ZJFlexibleLayoutDemo.xcodeproj/project.pbxproj index 9238ffa..7564d58 100644 --- a/ZJFlexibleLayoutDemo.xcodeproj/project.pbxproj +++ b/ZJFlexibleLayoutDemo.xcodeproj/project.pbxproj @@ -11,7 +11,6 @@ B44671221DF9BE6200B576D0 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B44671211DF9BE6200B576D0 /* ViewController.swift */; }; B44671271DF9BE6200B576D0 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B44671261DF9BE6200B576D0 /* Assets.xcassets */; }; B446712A1DF9BE6200B576D0 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B44671281DF9BE6200B576D0 /* LaunchScreen.storyboard */; }; - B474D1FA20F5272800BCC95B /* SwiftColors.swift in Sources */ = {isa = PBXBuildFile; fileRef = B474D1F920F5272800BCC95B /* SwiftColors.swift */; }; B49292EC1DF9C888000895B8 /* CustomCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = B49292EB1DF9C888000895B8 /* CustomCell.swift */; }; B49292EE1DF9C968000895B8 /* CustomHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = B49292ED1DF9C968000895B8 /* CustomHeader.swift */; }; ECA625FF0557F35DB0CED4A5 /* Pods_ZJFlexibleLayoutDemo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4211532F740F28DBB21C5106 /* Pods_ZJFlexibleLayoutDemo.framework */; }; @@ -40,7 +39,6 @@ B44671261DF9BE6200B576D0 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; B44671291DF9BE6200B576D0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; B446712B1DF9BE6200B576D0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - B474D1F920F5272800BCC95B /* SwiftColors.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SwiftColors.swift; path = ../../../Documents/Personal_Projects/ZJFlexibleLayout/ZJFlexibleLayoutDemo/SwiftColors.swift; sourceTree = ""; }; B49292EB1DF9C888000895B8 /* CustomCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomCell.swift; sourceTree = ""; }; B49292ED1DF9C968000895B8 /* CustomHeader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomHeader.swift; sourceTree = ""; }; C096844B2354EF326019BD1A /* Pods_ZJFlexibleLayout.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ZJFlexibleLayout.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -105,7 +103,6 @@ B44671211DF9BE6200B576D0 /* ViewController.swift */, B49292EB1DF9C888000895B8 /* CustomCell.swift */, B49292ED1DF9C968000895B8 /* CustomHeader.swift */, - B474D1F920F5272800BCC95B /* SwiftColors.swift */, B44671261DF9BE6200B576D0 /* Assets.xcassets */, B44671281DF9BE6200B576D0 /* LaunchScreen.storyboard */, B446712B1DF9BE6200B576D0 /* Info.plist */, @@ -149,7 +146,7 @@ B446711B1DF9BE6200B576D0 = { CreatedOnToolsVersion = 8.0; DevelopmentTeam = Z4H85W66CY; - LastSwiftMigration = 0900; + LastSwiftMigration = 1210; ProvisioningStyle = Automatic; }; }; @@ -159,6 +156,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, ); @@ -191,7 +189,7 @@ files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-ZJFlexibleLayoutDemo/Pods-ZJFlexibleLayoutDemo-frameworks.sh", + "${PODS_ROOT}/Target Support Files/Pods-ZJFlexibleLayoutDemo/Pods-ZJFlexibleLayoutDemo-frameworks.sh", "${BUILT_PRODUCTS_DIR}/ZJFlexibleLayout/ZJFlexibleLayout.framework", ); name = "[CP] Embed Pods Frameworks"; @@ -200,7 +198,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ZJFlexibleLayoutDemo/Pods-ZJFlexibleLayoutDemo-frameworks.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ZJFlexibleLayoutDemo/Pods-ZJFlexibleLayoutDemo-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; 33EC3ABAADAA72FE57AF6FD9 /* [CP] Check Pods Manifest.lock */ = { @@ -232,7 +230,6 @@ B49292EC1DF9C888000895B8 /* CustomCell.swift in Sources */, B44671201DF9BE6200B576D0 /* AppDelegate.swift in Sources */, B49292EE1DF9C968000895B8 /* CustomHeader.swift in Sources */, - B474D1FA20F5272800BCC95B /* SwiftColors.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -353,7 +350,7 @@ PRODUCT_BUNDLE_IDENTIFIER = cn.ZhijieZhang.ZJFlexibleLayoutDemo; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_SWIFT3_OBJC_INFERENCE = On; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -369,7 +366,7 @@ PRODUCT_BUNDLE_IDENTIFIER = cn.ZhijieZhang.ZJFlexibleLayoutDemo; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_SWIFT3_OBJC_INFERENCE = On; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/ZJFlexibleLayoutDemo/AppDelegate.swift b/ZJFlexibleLayoutDemo/AppDelegate.swift index e589f01..d506553 100644 --- a/ZJFlexibleLayoutDemo/AppDelegate.swift +++ b/ZJFlexibleLayoutDemo/AppDelegate.swift @@ -13,7 +13,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { window = UIWindow(frame: UIScreen.main.bounds) window?.rootViewController = UINavigationController(rootViewController: ViewController()) window?.makeKeyAndVisible() diff --git a/ZJFlexibleLayoutDemo/SwiftColors.swift b/ZJFlexibleLayoutDemo/SwiftColors.swift deleted file mode 100755 index 8da360a..0000000 --- a/ZJFlexibleLayoutDemo/SwiftColors.swift +++ /dev/null @@ -1,114 +0,0 @@ -// SwiftColors.swift -// -// Copyright (c) 2014 Doan Truong Thi -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#if os(iOS) - import UIKit - typealias SWColor = UIColor - #else - import Cocoa - typealias SWColor = NSColor -#endif - -public extension SWColor { - /** - Create non-autoreleased color with in the given hex string - Alpha will be set as 1 by default - - :param: hexString - :returns: color with the given hex string - */ - public convenience init?(hexString: String) { - self.init(hexString: hexString, alpha: 1.0) - } - - /** - Create non-autoreleased color with in the given hex string and alpha - - :param: hexString - :param: alpha - :returns: color with the given hex string and alpha - */ - public convenience init?(hexString: String, alpha: Float) { - var hex = hexString - - // Check for hash and remove the hash - if hex.hasPrefix("#") { - hex = hex.substring(from: hex.characters.index(hex.startIndex, offsetBy: 1)) - } - - if (hex.range(of: "(^[0-9A-Fa-f]{6}$)|(^[0-9A-Fa-f]{3}$)", options: .regularExpression) != nil) { - - // Deal with 3 character Hex strings - if hex.characters.count == 3 { - let redHex = hex.substring(to: hex.characters.index(hex.startIndex, offsetBy: 1)) - let greenHex = hex.substring(with: Range(hex.characters.index(hex.startIndex, offsetBy: 1) ..< hex.characters.index(hex.startIndex, offsetBy: 2))) - let blueHex = hex.substring(from: hex.characters.index(hex.startIndex, offsetBy: 2)) - - hex = redHex + redHex + greenHex + greenHex + blueHex + blueHex - } - - let redHex = hex.substring(to: hex.characters.index(hex.startIndex, offsetBy: 2)) - let greenHex = hex.substring(with: Range(hex.characters.index(hex.startIndex, offsetBy: 2) ..< hex.characters.index(hex.startIndex, offsetBy: 4))) - let blueHex = hex.substring(with: Range(hex.characters.index(hex.startIndex, offsetBy: 4) ..< hex.characters.index(hex.startIndex, offsetBy: 6))) - - var redInt: CUnsignedInt = 0 - var greenInt: CUnsignedInt = 0 - var blueInt: CUnsignedInt = 0 - - Scanner(string: redHex).scanHexInt32(&redInt) - Scanner(string: greenHex).scanHexInt32(&greenInt) - Scanner(string: blueHex).scanHexInt32(&blueInt) - - self.init(red: CGFloat(redInt) / 255.0, green: CGFloat(greenInt) / 255.0, blue: CGFloat(blueInt) / 255.0, alpha: CGFloat(alpha)) - } - else { - // Note: - // The swift 1.1 compiler is currently unable to destroy partially initialized classes in all cases, - // so it disallows formation of a situation where it would have to. We consider this a bug to be fixed - // in future releases, not a feature. -- Apple Forum - self.init() - return nil - } - } - - /** - Create non-autoreleased color with in the given hex value - Alpha will be set as 1 by default - - :param: hex - :returns: color with the given hex value - */ - public convenience init?(hex: Int) { - self.init(hex: hex, alpha: 1.0) - } - - /** - Create non-autoreleased color with in the given hex value and alpha - - :param: hex - :param: alpha - :returns: color with the given hex value and alpha - */ - public convenience init?(hex: Int, alpha: Float) { - self.init(hexString: String(format: "%06X", hex) , alpha: alpha) - } -} diff --git a/ZJFlexibleLayoutDemo/ViewController.swift b/ZJFlexibleLayoutDemo/ViewController.swift index 33c4350..bb8f889 100644 --- a/ZJFlexibleLayoutDemo/ViewController.swift +++ b/ZJFlexibleLayoutDemo/ViewController.swift @@ -39,7 +39,7 @@ class ViewController: UIViewController { //设置headerView let headerView = UILabel(frame: CGRect(x: 0, y: 10, width: kScreenWidth, height: 200)) headerView.textAlignment = .center - headerView.attributedText = NSAttributedString(string: "我是CollectionHeaderView", attributes: [NSAttributedStringKey.font: UIFont.systemFont(ofSize: 18), NSAttributedStringKey.foregroundColor: UIColor.white]) + headerView.attributedText = NSAttributedString(string: "我是CollectionHeaderView", attributes: [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 18), NSAttributedString.Key.foregroundColor: UIColor.white]) headerView.backgroundColor = systemGreenColor layout.collectionHeaderView = headerView @@ -48,7 +48,7 @@ class ViewController: UIViewController { collectionView.backgroundColor = .white collectionView.dataSource = self collectionView.register(CustomCell.self, forCellWithReuseIdentifier: "cell") - collectionView.register(CustomHeader.self, forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, withReuseIdentifier: "header") + collectionView.register(CustomHeader.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: "header") } } @@ -96,17 +96,17 @@ extension ViewController: UICollectionViewDataSource{ } func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { - let header = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionElementKindSectionHeader, withReuseIdentifier: "header", for: indexPath) as! CustomHeader + let header = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: "header", for: indexPath) as! CustomHeader header.label.text = "我是第\(indexPath.section)个sectionHeader" header.backgroundColor = .brown return header } } -let systemBlueColor = UIColor(hex: 0x428bca) ?? UIColor.blue -let systemRedColor = UIColor(hex: 0xd9534f) ?? UIColor.red -let systemGreenColor = UIColor(hex: 0x5cb85c) ?? UIColor.green -let systemYelloColor = UIColor(hex: 0xf0ad4e) ?? UIColor.yellow +let systemBlueColor = UIColor.blue +let systemRedColor = UIColor.red +let systemGreenColor = UIColor.green +let systemYelloColor = UIColor.yellow let colors = [systemBlueColor, systemRedColor, systemGreenColor, systemYelloColor] let kScreenBounds = UIScreen.main.bounds let kScreenSize = kScreenBounds.size