From 5c7102fad691c23494c52dbceac03e83cea27ec9 Mon Sep 17 00:00:00 2001 From: izumi Date: Fri, 5 Oct 2018 18:21:50 +0900 Subject: [PATCH] Swift4.2 --- NohanaImagePicker.xcodeproj/project.pbxproj | 4 ++-- NohanaImagePicker/AlbumListEmptyIndicator.swift | 14 +++++++------- NohanaImagePicker/AlbumListViewController.swift | 4 ++-- .../AnimatableNavigationController.swift | 2 +- NohanaImagePicker/AssetCell.swift | 2 +- .../AssetDetailListViewController.swift | 4 ++-- NohanaImagePicker/AssetListViewController.swift | 2 +- .../ContractingAnimationController.swift | 2 +- NohanaImagePicker/MomentViewController.swift | 4 ++-- .../NohanaImagePickerController.swift | 4 ++-- 10 files changed, 21 insertions(+), 21 deletions(-) diff --git a/NohanaImagePicker.xcodeproj/project.pbxproj b/NohanaImagePicker.xcodeproj/project.pbxproj index 044f34b..54aa711 100644 --- a/NohanaImagePicker.xcodeproj/project.pbxproj +++ b/NohanaImagePicker.xcodeproj/project.pbxproj @@ -613,7 +613,7 @@ SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -634,7 +634,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Release; }; diff --git a/NohanaImagePicker/AlbumListEmptyIndicator.swift b/NohanaImagePicker/AlbumListEmptyIndicator.swift index 492d4c9..e0a08f2 100644 --- a/NohanaImagePicker/AlbumListEmptyIndicator.swift +++ b/NohanaImagePicker/AlbumListEmptyIndicator.swift @@ -23,22 +23,22 @@ class AlbumListEmptyIndicator: UILabel { centerStyle.alignment = NSTextAlignment.center let messageAttributes = [ - NSAttributedStringKey.foregroundColor : config.color.empty ?? UIColor(red: 0x88/0xff, green: 0x88/0xff, blue: 0x88/0xff, alpha: 1), - NSAttributedStringKey.font : UIFont.systemFont(ofSize: 26), - NSAttributedStringKey.paragraphStyle : centerStyle + NSAttributedString.Key.foregroundColor : config.color.empty ?? UIColor(red: 0x88/0xff, green: 0x88/0xff, blue: 0x88/0xff, alpha: 1), + NSAttributedString.Key.font : UIFont.systemFont(ofSize: 26), + NSAttributedString.Key.paragraphStyle : centerStyle ] let messageText = NSAttributedString(string: message, attributes: messageAttributes) let descriptionAttributes = [ - NSAttributedStringKey.foregroundColor : config.color.empty ?? UIColor(red: 0x88/0xff, green: 0x88/0xff, blue: 0x88/0xff, alpha: 1), - NSAttributedStringKey.font : UIFont.systemFont(ofSize: 14), - NSAttributedStringKey.paragraphStyle : centerStyle + NSAttributedString.Key.foregroundColor : config.color.empty ?? UIColor(red: 0x88/0xff, green: 0x88/0xff, blue: 0x88/0xff, alpha: 1), + NSAttributedString.Key.font : UIFont.systemFont(ofSize: 14), + NSAttributedString.Key.paragraphStyle : centerStyle ] let descriptionText = NSAttributedString(string: description, attributes: descriptionAttributes) let attributedText = NSMutableAttributedString() attributedText.append(messageText) - attributedText.append(NSAttributedString(string: "\n\n", attributes: [NSAttributedStringKey.font : UIFont.systemFont(ofSize: 6)])) + attributedText.append(NSAttributedString(string: "\n\n", attributes: [NSAttributedString.Key.font : UIFont.systemFont(ofSize: 6)])) attributedText.append(descriptionText) self.numberOfLines = 0 diff --git a/NohanaImagePicker/AlbumListViewController.swift b/NohanaImagePicker/AlbumListViewController.swift index 32207f1..fa13710 100644 --- a/NohanaImagePicker/AlbumListViewController.swift +++ b/NohanaImagePicker/AlbumListViewController.swift @@ -240,7 +240,7 @@ class AlbumListViewController: UITableViewController, EmptyIndicatable, Activity var isLoading = true func setUpActivityIndicator() { - activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: .gray) + activityIndicator = UIActivityIndicatorView(style: .gray) let screenRect = Size.screenRectWithoutAppBar(self) activityIndicator?.center = CGPoint(x: screenRect.size.width / 2, y: screenRect.size.height / 2) activityIndicator?.startAnimating() @@ -261,7 +261,7 @@ extension UIViewController { let infoButton = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil) infoButton.isEnabled = false - infoButton.setTitleTextAttributes([NSAttributedStringKey.font: UIFont.systemFont(ofSize: 14), NSAttributedStringKey.foregroundColor: UIColor.black], for: UIControlState()) + infoButton.setTitleTextAttributes([NSAttributedString.Key.font: UIFont.systemFont(ofSize: 14), NSAttributedString.Key.foregroundColor: UIColor.black], for: UIControl.State()) self.toolbarItems = [leftSpace, infoButton, rightSpace] } diff --git a/NohanaImagePicker/AnimatableNavigationController.swift b/NohanaImagePicker/AnimatableNavigationController.swift index bad1b0c..3a44a38 100644 --- a/NohanaImagePicker/AnimatableNavigationController.swift +++ b/NohanaImagePicker/AnimatableNavigationController.swift @@ -25,7 +25,7 @@ class AnimatableNavigationController: UINavigationController, UINavigationContro self.delegate = self } - func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationControllerOperation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? { + func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationController.Operation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? { switch operation { case .push where fromVC is AssetListViewController: diff --git a/NohanaImagePicker/AssetCell.swift b/NohanaImagePicker/AssetCell.swift index 726747b..ca1a299 100644 --- a/NohanaImagePicker/AssetCell.swift +++ b/NohanaImagePicker/AssetCell.swift @@ -30,7 +30,7 @@ class AssetCell: UICollectionViewCell { let droppedImage: UIImage? = nohanaImagePickerController.config.image.droppedSmall ?? UIImage(named: "btn_select_m", in: nohanaImagePickerController.assetBundle, compatibleWith: nil) let pickedImage: UIImage? = nohanaImagePickerController.config.image.pickedSmall ?? UIImage(named: "btn_selected_m", in: nohanaImagePickerController.assetBundle, compatibleWith: nil) - pickButton.setImage(droppedImage, for: UIControlState()) + pickButton.setImage(droppedImage, for: UIControl.State()) pickButton.setImage(pickedImage, for: .selected) } } diff --git a/NohanaImagePicker/AssetDetailListViewController.swift b/NohanaImagePicker/AssetDetailListViewController.swift index b28769e..06cd7e3 100644 --- a/NohanaImagePicker/AssetDetailListViewController.swift +++ b/NohanaImagePicker/AssetDetailListViewController.swift @@ -38,7 +38,7 @@ class AssetDetailListViewController: AssetListViewController { let droppedImage: UIImage? = nohanaImagePickerController.config.image.droppedLarge ?? UIImage(named: "btn_select_l", in: nohanaImagePickerController.assetBundle, compatibleWith: nil) let pickedImage: UIImage? = nohanaImagePickerController.config.image.pickedLarge ?? UIImage(named: "btn_selected_l", in: nohanaImagePickerController.assetBundle, compatibleWith: nil) - pickButton.setImage(droppedImage, for: UIControlState()) + pickButton.setImage(droppedImage, for: UIControl.State()) pickButton.setImage(pickedImage, for: .selected) } } @@ -76,7 +76,7 @@ class AssetDetailListViewController: AssetListViewController { } DispatchQueue.main.async { let toIndexPath = IndexPath(item: indexPath.item, section: 0) - self.collectionView?.scrollToItem(at: toIndexPath, at: UICollectionViewScrollPosition.centeredHorizontally, animated: false) + self.collectionView?.scrollToItem(at: toIndexPath, at: UICollectionView.ScrollPosition.centeredHorizontally, animated: false) } } diff --git a/NohanaImagePicker/AssetListViewController.swift b/NohanaImagePicker/AssetListViewController.swift index 8fe2e1d..8b71c3a 100644 --- a/NohanaImagePicker/AssetListViewController.swift +++ b/NohanaImagePicker/AssetListViewController.swift @@ -35,7 +35,7 @@ class AssetListViewController: UICollectionViewController, UICollectionViewDeleg return CGSize.zero } var numberOfColumns = nohanaImagePickerController.numberOfColumnsInLandscape - if UIInterfaceOrientationIsPortrait(UIApplication.shared.statusBarOrientation) { + if UIApplication.shared.statusBarOrientation.isPortrait { numberOfColumns = nohanaImagePickerController.numberOfColumnsInPortrait } let cellMargin: CGFloat = 2 diff --git a/NohanaImagePicker/ContractingAnimationController.swift b/NohanaImagePicker/ContractingAnimationController.swift index b807909..77b30a1 100644 --- a/NohanaImagePicker/ContractingAnimationController.swift +++ b/NohanaImagePicker/ContractingAnimationController.swift @@ -77,7 +77,7 @@ class ContractingAnimationController: NSObject, UIViewControllerAnimatedTransiti UIView.animate( withDuration: transitionDuration(using: transitionContext), delay: 0, - options: UIViewAnimationOptions(), + options: UIView.AnimationOptions(), animations: { toVC.view.alpha = 1 contractingImageView.frame = Size.contractingAnimationToCellRect(toVC, toCell: toCell) diff --git a/NohanaImagePicker/MomentViewController.swift b/NohanaImagePicker/MomentViewController.swift index dd807e7..ff5fa6d 100644 --- a/NohanaImagePicker/MomentViewController.swift +++ b/NohanaImagePicker/MomentViewController.swift @@ -99,7 +99,7 @@ class MomentViewController: AssetListViewController, ActivityIndicatable { override func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { switch kind { - case UICollectionElementKindSectionHeader: + case UICollectionView.elementKindSectionHeader: let album = momentAlbumList[indexPath.section] guard let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "MomentHeader", for: indexPath) as? MomentSectionHeaderView else { fatalError("failed to create MomentHeader") @@ -125,7 +125,7 @@ class MomentViewController: AssetListViewController, ActivityIndicatable { var isLoading = true func setUpActivityIndicator() { - activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: .gray) + activityIndicator = UIActivityIndicatorView(style: .gray) let screenRect = Size.screenRectWithoutAppBar(self) activityIndicator?.center = CGPoint(x: screenRect.size.width / 2, y: screenRect.size.height / 2) activityIndicator?.startAnimating() diff --git a/NohanaImagePicker/NohanaImagePickerController.swift b/NohanaImagePicker/NohanaImagePickerController.swift index a1fce79..ffea723 100644 --- a/NohanaImagePicker/NohanaImagePickerController.swift +++ b/NohanaImagePicker/NohanaImagePickerController.swift @@ -106,9 +106,9 @@ open class NohanaImagePickerController: UIViewController { guard let navigationController = storyboard.instantiateViewController(withIdentifier: viewControllerId) as? UINavigationController else { fatalError("navigationController init failed.") } - addChildViewController(navigationController) + addChild(navigationController) view.addSubview(navigationController.view) - navigationController.didMove(toParentViewController: self) + navigationController.didMove(toParent: self) // setup albumListViewController guard let albumListViewController = navigationController.topViewController as? AlbumListViewController else {