From 7f4ab0c1f1f37f84e1413b24fab8885f10f212af Mon Sep 17 00:00:00 2001 From: Alex Hill Date: Wed, 21 Jun 2017 12:09:35 -0700 Subject: [PATCH] - Update library to support iOS 9.0 - Update README.md --- AXPhotoViewer.podspec | 4 ++-- Example/Podfile.lock | 6 +++--- README.md | 17 +++++++++++++--- Source/Classes/CaptionView.swift | 34 +++++++++++++++++++++++++++----- 4 files changed, 48 insertions(+), 13 deletions(-) diff --git a/AXPhotoViewer.podspec b/AXPhotoViewer.podspec index 4495ff4..fcc7410 100644 --- a/AXPhotoViewer.podspec +++ b/AXPhotoViewer.podspec @@ -1,13 +1,13 @@ Pod::Spec.new do |s| s.name = "AXPhotoViewer" - s.version = "1.0" + s.version = "1.0-beta.5" s.license = { :type => 'MIT', :file => 'LICENSE.md' } s.summary = "An iPhone/iPad photo gallery viewer, useful for viewing a large number of photos." s.homepage = "https://github.com/alexhillc/AXPhotoViewer" s.author = { "Alex Hill" => "alexhill.c@gmail.com" } s.source = { :git => "https://github.com/alexhillc/AXPhotoViewer.git", :tag => "v#{s.version}" } - s.platform = :ios, '10.0' + s.platform = :ios, '9.0' s.requires_arc = true s.default_subspec = 'Core' diff --git a/Example/Podfile.lock b/Example/Podfile.lock index d4d5320..6f79e53 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -1,7 +1,7 @@ PODS: - - AXPhotoViewer/Core (1.0): + - AXPhotoViewer/Core (1.0-beta.1): - FLAnimatedImage (>= 1.0.0) - - AXPhotoViewer/Lite (1.0): + - AXPhotoViewer/Lite (1.0-beta.1): - AXPhotoViewer/Core - FLAnimatedImage (1.0.12) - Reveal-SDK (8) @@ -15,7 +15,7 @@ EXTERNAL SOURCES: :path: "../AXPhotoViewer.podspec" SPEC CHECKSUMS: - AXPhotoViewer: 9affee1d8f6d71a062c0922ea8935cf27e429a3c + AXPhotoViewer: 9c15d3ecaa2b8d63c934fdc8b666b6b47e8fe2b7 FLAnimatedImage: 4a0b56255d9b05f18b6dd7ee06871be5d3b89e31 Reveal-SDK: 43be4e662864e937960d0d04d005135e29c4e53b diff --git a/README.md b/README.md index d6c633a..7b8bd08 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,27 @@ # AXPhotoViewer -AXPhotoViewer is an iOS photo viewer that is useful for viewing a very large (or very small!) amount of images and GIFs. This library supports contextual presentation and dismissal, interactive "flick-to-dismiss" behavior, and easily integrates with many third party async image downloading/caching libraries. +AXPhotoViewer is an iOS photo viewer that is useful for viewing a very large (or very small!) amount of images and GIFs. This library supports contextual presentation and dismissal, interactive "flick-to-dismiss" behavior, and easily integrates with many third party async image downloading/caching libraries. While AXPhotoViewer has many configurable properties on each of its modules, it is easy to throw down some initialization code and get started: ```swift let dataSource = PhotosDataSource(photos: self.photos, prefetchBehavior: .regular) let pagingConfig = PagingConfig(navigationOrientation: .horizontal) -let transitionInfo = TransitionInfo(startingView: self.startinImageView) { [weak self] (photo, index) -> UIImageView? in +let transitionInfo = TransitionInfo(startingView: self.startingImageView) { [weak self] (photo, index) -> UIImageView? in return self?.endingImageView } - + let photosViewController = PhotosViewController(dataSource: dataSource, pagingConfig: pagingConfig, transitionInfo: transitionInfo) self.present(photosViewController, animated: true, completion: nil) ``` +### Objective-C interoperability +This library fully supports interop between Objective-C and Swift codebases. If you run into any issues with this, please open a Github issue or submit a pull request with the suggested changes. + +### Installation +Installation can easily be done through Cocoapods: +```ruby +pod install 'AXPhotoViewer', '~> 1.0.0-beta.5' +``` +or, if you prefer not to use Cocoapods, add the contents of the 'Source' directory to your project to get started. + +More info to come. diff --git a/Source/Classes/CaptionView.swift b/Source/Classes/CaptionView.swift index 78e666d..5376dc2 100644 --- a/Source/Classes/CaptionView.swift +++ b/Source/Classes/CaptionView.swift @@ -38,8 +38,14 @@ import UIKit var defaultTitleAttributes: [String: Any] { get { - let fontDescriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .body, + var fontDescriptor: UIFontDescriptor + if #available(iOS 10.0, *) { + fontDescriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .body, compatibleWith: self.traitCollection) + } else { + fontDescriptor = UIFont.preferredFont(forTextStyle: .body).fontDescriptor + } + let font = UIFont.systemFont(ofSize: fontDescriptor.pointSize, weight: UIFontWeightBold) let textColor = UIColor.white @@ -52,8 +58,14 @@ import UIKit var defaultDescriptionAttributes: [String: Any] { get { - let fontDescriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .body, - compatibleWith: self.traitCollection) + var fontDescriptor: UIFontDescriptor + if #available(iOS 10.0, *) { + fontDescriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .body, + compatibleWith: self.traitCollection) + } else { + fontDescriptor = UIFont.preferredFont(forTextStyle: .body).fontDescriptor + } + let font = UIFont.systemFont(ofSize: fontDescriptor.pointSize, weight: UIFontWeightLight) let textColor = UIColor.lightGray @@ -66,8 +78,14 @@ import UIKit var defaultCreditAttributes: [String: Any] { get { - let fontDescriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .caption1, + var fontDescriptor: UIFontDescriptor + if #available(iOS 10.0, *) { + fontDescriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .caption1, compatibleWith: self.traitCollection) + } else { + fontDescriptor = UIFont.preferredFont(forTextStyle: .caption1).fontDescriptor + } + let font = UIFont.systemFont(ofSize: fontDescriptor.pointSize, weight: UIFontWeightLight) let textColor = UIColor.gray @@ -233,7 +251,13 @@ import UIKit return } - let newFontDescriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: fontTextStyle, compatibleWith: self?.traitCollection) + var newFontDescriptor: UIFontDescriptor + if #available(iOS 10.0, *) { + newFontDescriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: fontTextStyle, compatibleWith: self?.traitCollection) + } else { + newFontDescriptor = UIFont.preferredFont(forTextStyle: fontTextStyle).fontDescriptor + } + let newFont = oldFont.withSize(newFontDescriptor.pointSize) fontAdjustedAttributedString.removeAttribute(NSFontAttributeName, range: range) fontAdjustedAttributedString.addAttribute(NSFontAttributeName, value: newFont, range: range)