diff --git a/Cartfile b/Cartfile index 8469903..e672b88 100644 --- a/Cartfile +++ b/Cartfile @@ -1,2 +1 @@ -github "robb/Cartography" github "hyperoslo/Pages" diff --git a/Cartfile.resolved b/Cartfile.resolved index 444a7d4..86f3e11 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,2 +1 @@ github "hyperoslo/Pages" "2.0.2" -github "robb/Cartography" "2.0.0" diff --git a/Example/Parallax/Parallax.xcodeproj/project.pbxproj b/Example/Parallax/Parallax.xcodeproj/project.pbxproj index a32dd05..fffabc8 100644 --- a/Example/Parallax/Parallax.xcodeproj/project.pbxproj +++ b/Example/Parallax/Parallax.xcodeproj/project.pbxproj @@ -213,14 +213,12 @@ ); inputPaths = ( "${SRCROOT}/Pods/Target Support Files/Pods-Parallax/Pods-Parallax-frameworks.sh", - "${BUILT_PRODUCTS_DIR}/Cartography/Cartography.framework", "${BUILT_PRODUCTS_DIR}/Hue/Hue.framework", "${BUILT_PRODUCTS_DIR}/Pages/Pages.framework", "${BUILT_PRODUCTS_DIR}/Presentation/Presentation.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cartography.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Hue.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Pages.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Presentation.framework", @@ -366,6 +364,7 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = Parallax/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -382,6 +381,7 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = Parallax/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/Example/Parallax/Podfile b/Example/Parallax/Podfile index 856af66..069c1ed 100644 --- a/Example/Parallax/Podfile +++ b/Example/Parallax/Podfile @@ -1,6 +1,6 @@ use_frameworks! -platform :ios, '8.0' +platform :ios, '9.0' pod 'Presentation', path: '../../' pod 'Hue' diff --git a/Example/Parallax/Podfile.lock b/Example/Parallax/Podfile.lock index 719542b..1f1c616 100644 --- a/Example/Parallax/Podfile.lock +++ b/Example/Parallax/Podfile.lock @@ -1,10 +1,8 @@ PODS: - - Cartography (2.0.0) - - Hue (2.0.1) + - Hue (3.0.1) - Pages (2.0.2) - - Presentation (3.1.0): - - Cartography - - Pages + - Presentation (4.1.0): + - Pages (~> 2.0) DEPENDENCIES: - Hue @@ -15,11 +13,10 @@ EXTERNAL SOURCES: :path: ../../ SPEC CHECKSUMS: - Cartography: d295eb25ab54bb57eecd8c2f04e9648c850f1281 - Hue: 354caec055fdc9d38b5ef33ca2e7224721843baf + Hue: 93e852fa6211ab35922ad8c293f51c43d6c79eb2 Pages: 5564ac6035c48fef7a837049314f57507d263b11 - Presentation: 07f001419368d0ece73285f238b1dc3852462f23 + Presentation: b717a7e0bff6af8e028998269114a344d5c114e4 -PODFILE CHECKSUM: 8a38e1ff9630071a018856bbaebe49be27870e49 +PODFILE CHECKSUM: 979718cbe7e3509ed288250a31b6c6036f4f9943 -COCOAPODS: 1.3.1 +COCOAPODS: 1.4.0 diff --git a/Example/Tutorial/Podfile b/Example/Tutorial/Podfile index 28d416e..b95f97a 100644 --- a/Example/Tutorial/Podfile +++ b/Example/Tutorial/Podfile @@ -2,7 +2,7 @@ source 'https://github.com/CocoaPods/Specs.git' use_frameworks! -platform :ios, '8.0' +platform :ios, '9.0' pod 'Presentation', path: '../../' pod 'Hue' diff --git a/Example/Tutorial/Podfile.lock b/Example/Tutorial/Podfile.lock index 603396a..e2fec94 100644 --- a/Example/Tutorial/Podfile.lock +++ b/Example/Tutorial/Podfile.lock @@ -1,10 +1,8 @@ PODS: - - Cartography (2.0.0) - - Hue (1.2.0) + - Hue (3.0.1) - Pages (2.0.2) - - Presentation (3.1.0): - - Cartography - - Pages + - Presentation (4.1.0): + - Pages (~> 2.0) DEPENDENCIES: - Hue @@ -15,11 +13,10 @@ EXTERNAL SOURCES: :path: ../../ SPEC CHECKSUMS: - Cartography: d295eb25ab54bb57eecd8c2f04e9648c850f1281 - Hue: 0705083b7aff40334033373e6293ec1215285ac2 + Hue: 93e852fa6211ab35922ad8c293f51c43d6c79eb2 Pages: 5564ac6035c48fef7a837049314f57507d263b11 - Presentation: 07f001419368d0ece73285f238b1dc3852462f23 + Presentation: b717a7e0bff6af8e028998269114a344d5c114e4 -PODFILE CHECKSUM: a2be853ebf7792783dc915c68a50d0f469a3c2ec +PODFILE CHECKSUM: fdf662532b7595886c0398895df5b6e99fbfa147 -COCOAPODS: 1.3.1 +COCOAPODS: 1.4.0 diff --git a/Example/Tutorial/Tutorial.xcodeproj/project.pbxproj b/Example/Tutorial/Tutorial.xcodeproj/project.pbxproj index d2f8213..19b219e 100644 --- a/Example/Tutorial/Tutorial.xcodeproj/project.pbxproj +++ b/Example/Tutorial/Tutorial.xcodeproj/project.pbxproj @@ -202,14 +202,12 @@ ); inputPaths = ( "${SRCROOT}/Pods/Target Support Files/Pods-Tutorial/Pods-Tutorial-frameworks.sh", - "${BUILT_PRODUCTS_DIR}/Cartography/Cartography.framework", "${BUILT_PRODUCTS_DIR}/Hue/Hue.framework", "${BUILT_PRODUCTS_DIR}/Pages/Pages.framework", "${BUILT_PRODUCTS_DIR}/Presentation/Presentation.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cartography.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Hue.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Pages.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Presentation.framework", @@ -352,6 +350,7 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = Tutorial/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = Tutorial; @@ -368,6 +367,7 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = Tutorial/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = Tutorial; diff --git a/Presentation.podspec b/Presentation.podspec index 294d699..070e286 100644 --- a/Presentation.podspec +++ b/Presentation.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "Presentation" s.summary = "Presentation helps you to make tutorials, release notes and animated pages." - s.version = "4.0.0" + s.version = "4.1.0" s.homepage = "https://github.com/hyperoslo/Presentation" s.license = 'MIT' s.author = { "Hyper" => "ios@hyper.no" } @@ -13,5 +13,4 @@ Pod::Spec.new do |s| s.source_files = 'Source/**/*' s.dependency 'Pages', '~> 2.0' - s.dependency 'Cartography', '~> 2.0' end diff --git a/Presentation.xcodeproj/project.pbxproj b/Presentation.xcodeproj/project.pbxproj index b10ca5b..5d28520 100644 --- a/Presentation.xcodeproj/project.pbxproj +++ b/Presentation.xcodeproj/project.pbxproj @@ -17,7 +17,6 @@ D523B0EE1C43AC70001AD1EC /* PresentationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D523B0E41C43AC70001AD1EC /* PresentationController.swift */; }; D523B0EF1C43AC70001AD1EC /* SlideController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D523B0E51C43AC70001AD1EC /* SlideController.swift */; }; D523B0F21C43AE94001AD1EC /* Pages.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D523B0F01C43AE94001AD1EC /* Pages.framework */; }; - D523B0F31C43AE94001AD1EC /* Cartography.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D523B0F11C43AE94001AD1EC /* Cartography.framework */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -33,7 +32,6 @@ D523B0E41C43AC70001AD1EC /* PresentationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PresentationController.swift; sourceTree = ""; }; D523B0E51C43AC70001AD1EC /* SlideController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SlideController.swift; sourceTree = ""; }; D523B0F01C43AE94001AD1EC /* Pages.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Pages.framework; path = Carthage/Build/iOS/Pages.framework; sourceTree = ""; }; - D523B0F11C43AE94001AD1EC /* Cartography.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cartography.framework; path = Carthage/Build/iOS/Cartography.framework; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -42,7 +40,6 @@ buildActionMask = 2147483647; files = ( D523B0F21C43AE94001AD1EC /* Pages.framework in Frameworks */, - D523B0F31C43AE94001AD1EC /* Cartography.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -111,7 +108,6 @@ isa = PBXGroup; children = ( D523B0F01C43AE94001AD1EC /* Pages.framework */, - D523B0F11C43AE94001AD1EC /* Cartography.framework */, ); name = Frameworks; sourceTree = ""; @@ -198,7 +194,6 @@ ); inputPaths = ( "$(SRCROOT)/Carthage/Build/iOS/Pages.framework", - "$(SRCROOT)/Carthage/Build/iOS/Cartography.framework", ); outputPaths = ( ); diff --git a/Source/Content.swift b/Source/Content.swift index f271272..c3b7b1a 100644 --- a/Source/Content.swift +++ b/Source/Content.swift @@ -1,5 +1,4 @@ import UIKit -import Cartography public final class Content: NSObject { public var view: UIView @@ -12,7 +11,7 @@ public final class Content: NSObject { } public private(set) var initialPosition: Position - private let group = ConstraintGroup() + private var constraints = [NSLayoutConstraint]() public init(view: UIView, position: Position, centered: Bool = true) { self.view = view @@ -22,40 +21,70 @@ public final class Content: NSObject { super.init() - constrain(view) { [unowned self] view in - view.width == self.view.frame.width - view.height == self.view.frame.height - } + view.translatesAutoresizingMaskIntoConstraints = false + setupSizeConstraints() } public func layout() { - guard view.superview != nil else { + guard let superview = view.superview else { return } - constrain(view, replace: group) { [unowned self] view in - let x = self.position.left == 0.0 - ? view.superview!.left * 1.0 - : view.superview!.right * self.position.left - let y = self.position.top == 0.0 - ? view.superview!.top * 1.0 - : view.superview!.bottom * self.position.top - - if self.centered { - view.centerX == x - view.centerY == y - } else { - view.left == x - view.top == y - } - } - + NSLayoutConstraint.deactivate(constraints) + + let xAttribute: NSLayoutAttribute = centered ? .centerX : .leading + let yAttribute: NSLayoutAttribute = centered ? .centerY : .top + let xSuperAttribute: NSLayoutAttribute = position.left == 0 ? .leading : .trailing + let ySuperAttribute: NSLayoutAttribute = position.top == 0 ? .top : .bottom + let xMultiplier: CGFloat = position.left == 0 ? 1 : position.left + let yMultiplier: CGFloat = position.top == 0 ? 1 : position.top + + constraints = [ + NSLayoutConstraint( + item: view, + attribute: xAttribute, + relatedBy: .equal, + toItem: superview, + attribute: xSuperAttribute, + multiplier: xMultiplier, + constant: 0 + ), + NSLayoutConstraint( + item: view, + attribute: yAttribute, + relatedBy: .equal, + toItem: superview, + attribute: ySuperAttribute, + multiplier: yMultiplier, + constant: 0 + ) + ] + + NSLayoutConstraint.activate(constraints) view.layoutIfNeeded() } public func animate() { view.superview!.layoutIfNeeded() } + + private func setupSizeConstraints() { + makeSizeConstraint(attribute: .width, constant: view.frame.width).isActive = true + makeSizeConstraint(attribute: .height, constant: view.frame.height).isActive = true + } + + private func makeSizeConstraint(attribute: NSLayoutAttribute, + constant: CGFloat) -> NSLayoutConstraint { + return NSLayoutConstraint( + item: view, + attribute: attribute, + relatedBy: .equal, + toItem: nil, + attribute: .notAnAttribute, + multiplier: 1, + constant: constant + ) + } } public extension Content {