diff --git a/RAReorderableLayout-Demo/RAReorderableLayout-Demo.xcodeproj/project.pbxproj b/RAReorderableLayout-Demo/RAReorderableLayout-Demo.xcodeproj/project.pbxproj index 26bcfa3..7b68734 100644 --- a/RAReorderableLayout-Demo/RAReorderableLayout-Demo.xcodeproj/project.pbxproj +++ b/RAReorderableLayout-Demo/RAReorderableLayout-Demo.xcodeproj/project.pbxproj @@ -153,6 +153,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, ); @@ -304,7 +305,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = "com.ryo.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -326,7 +327,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = "com.ryo.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 2.3; + SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/RAReorderableLayout-Demo/RAReorderableLayout-Demo/HorizontalViewController.swift b/RAReorderableLayout-Demo/RAReorderableLayout-Demo/HorizontalViewController.swift index 2b206aa..0e04804 100644 --- a/RAReorderableLayout-Demo/RAReorderableLayout-Demo/HorizontalViewController.swift +++ b/RAReorderableLayout-Demo/RAReorderableLayout-Demo/HorizontalViewController.swift @@ -69,7 +69,7 @@ class HorizontalViewController: UIViewController, RAReorderableLayoutDelegate, R } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { - return UIEdgeInsetsMake(0, 20.0, 0, 20.0) + return UIEdgeInsets(top: 0, left: 20.0, bottom: 0, right: 20.0) } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { @@ -93,7 +93,7 @@ class HorizontalViewController: UIViewController, RAReorderableLayoutDelegate, R } func scrollTrigerEdgeInsetsInCollectionView(_ collectionView: UICollectionView) -> UIEdgeInsets { - return UIEdgeInsetsMake(0, 50, 0, 50) + return UIEdgeInsets(top: 0, left: 50, bottom: 0, right: 50) } func scrollSpeedValueInCollectionView(_ collectionView: UICollectionView) -> CGFloat { diff --git a/RAReorderableLayout-Demo/RAReorderableLayout-Demo/Main.storyboard b/RAReorderableLayout-Demo/RAReorderableLayout-Demo/Main.storyboard index b361ead..83dd732 100644 --- a/RAReorderableLayout-Demo/RAReorderableLayout-Demo/Main.storyboard +++ b/RAReorderableLayout-Demo/RAReorderableLayout-Demo/Main.storyboard @@ -1,8 +1,12 @@ - - + + + + + - + + @@ -10,7 +14,7 @@ - + @@ -30,14 +34,14 @@ - + - + - + @@ -93,10 +97,10 @@ - + - + @@ -152,7 +156,7 @@ - + @@ -174,15 +178,15 @@ - - - - + - + + + + @@ -191,15 +195,15 @@ - - - - + - + + + + @@ -222,20 +226,20 @@ - + - + - - + + - + @@ -269,7 +273,7 @@ - + @@ -318,29 +322,28 @@ - + - - + + - + - - + - + diff --git a/RAReorderableLayout-Demo/RAReorderableLayout-Demo/VerticalViewController.swift b/RAReorderableLayout-Demo/RAReorderableLayout-Demo/VerticalViewController.swift index 4a75848..3b03534 100644 --- a/RAReorderableLayout-Demo/RAReorderableLayout-Demo/VerticalViewController.swift +++ b/RAReorderableLayout-Demo/RAReorderableLayout-Demo/VerticalViewController.swift @@ -37,7 +37,7 @@ class VerticalViewController: UIViewController, RAReorderableLayoutDelegate, RAR override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() - collectionView.contentInset = UIEdgeInsetsMake(topLayoutGuide.length, 0, 0, 0) + collectionView.contentInset = UIEdgeInsets(top: topLayoutGuide.length, left: 0, bottom: 0, right: 0) } // RAReorderableLayout delegate datasource @@ -66,7 +66,7 @@ class VerticalViewController: UIViewController, RAReorderableLayoutDelegate, RAR } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { - return UIEdgeInsetsMake(0, 0, 2.0, 0) + return UIEdgeInsets(top: 0, left: 0, bottom: 2.0, right: 0) } func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { @@ -100,6 +100,12 @@ class VerticalViewController: UIViewController, RAReorderableLayoutDelegate, RAR } func collectionView(_ collectionView: UICollectionView, at atIndexPath: IndexPath, didMoveTo toIndexPath: IndexPath) { + print("==========atIndexPath=======") + print(atIndexPath) + print("==========atIndexPath=======") + print("==========toIndexPath=======") + print(toIndexPath) + print("==========toIndexPath=======") var photo: UIImage if (atIndexPath as NSIndexPath).section == 0 { photo = imagesForSection0.remove(at: (atIndexPath as NSIndexPath).item) @@ -115,7 +121,7 @@ class VerticalViewController: UIViewController, RAReorderableLayoutDelegate, RAR } func scrollTrigerEdgeInsetsInCollectionView(_ collectionView: UICollectionView) -> UIEdgeInsets { - return UIEdgeInsetsMake(100.0, 100.0, 100.0, 100.0) + return UIEdgeInsets(top: 100.0, left: 100.0, bottom: 100.0, right: 100.0) } func collectionView(_ collectionView: UICollectionView, reorderingItemAlphaInSection section: Int) -> CGFloat { @@ -127,7 +133,7 @@ class VerticalViewController: UIViewController, RAReorderableLayoutDelegate, RAR } func scrollTrigerPaddingInCollectionView(_ collectionView: UICollectionView) -> UIEdgeInsets { - return UIEdgeInsetsMake(collectionView.contentInset.top, 0, collectionView.contentInset.bottom, 0) + return UIEdgeInsets(top: collectionView.contentInset.top, left: 0, bottom: collectionView.contentInset.bottom, right: 0) } } @@ -156,7 +162,7 @@ class RACollectionViewCell: UICollectionViewCell { private func configure() { imageView = UIImageView() imageView.autoresizingMask = [.flexibleWidth, .flexibleHeight] - imageView.contentMode = UIViewContentMode.scaleAspectFill + imageView.contentMode = UIView.ContentMode.scaleAspectFill addSubview(imageView) hilightedCover = UIView() diff --git a/RAReorderableLayout-Demo/RAReorderableLayout-Demo/ViewController.swift b/RAReorderableLayout-Demo/RAReorderableLayout-Demo/ViewController.swift index dfbebd5..c3032a8 100644 --- a/RAReorderableLayout-Demo/RAReorderableLayout-Demo/ViewController.swift +++ b/RAReorderableLayout-Demo/RAReorderableLayout-Demo/ViewController.swift @@ -33,11 +33,11 @@ class ViewController: UIViewController { let color2: UIColor = UIColor(red: num3, green: num2, blue: num1, alpha: 1.0) if (num1 + num2 + num3) / 3.0 >= 0.5 { - verticalButton.setTitleColor(UIColor.black, for: UIControlState()) - horizontalButton.setTitleColor(UIColor.black, for: UIControlState()) + verticalButton.setTitleColor(UIColor.black, for: UIControl.State()) + horizontalButton.setTitleColor(UIColor.black, for: UIControl.State()) }else { - verticalButton.setTitleColor(UIColor.white, for: UIControlState()) - horizontalButton.setTitleColor(UIColor.white, for: UIControlState()) + verticalButton.setTitleColor(UIColor.white, for: UIControl.State()) + horizontalButton.setTitleColor(UIColor.white, for: UIControl.State()) } verticalButton.backgroundColor = color1 diff --git a/RAReorderableLayout/RAReorderableLayout.swift b/RAReorderableLayout/RAReorderableLayout.swift index 65c7130..8a3df6c 100644 --- a/RAReorderableLayout/RAReorderableLayout.swift +++ b/RAReorderableLayout/RAReorderableLayout.swift @@ -108,7 +108,7 @@ open class RAReorderableLayout: UICollectionViewFlowLayout, UIGestureRecognizerD fileprivate var fakeCellCenter: CGPoint? - fileprivate var trigerInsets = UIEdgeInsetsMake(100.0, 100.0, 100.0, 100.0) + fileprivate var trigerInsets = UIEdgeInsets(top: 100.0, left: 100.0, bottom: 100.0, right: 100.0) fileprivate var trigerPadding = UIEdgeInsets.zero @@ -236,7 +236,7 @@ open class RAReorderableLayout: UICollectionViewFlowLayout, UIGestureRecognizerD } displayLink = CADisplayLink(target: self, selector: #selector(RAReorderableLayout.continuousScroll)) - displayLink!.add(to: RunLoop.main, forMode: RunLoopMode.commonModes) + displayLink!.add(to: RunLoop.main, forMode: RunLoop.Mode.common) } fileprivate func invalidateDisplayLink() { @@ -292,7 +292,7 @@ open class RAReorderableLayout: UICollectionViewFlowLayout, UIGestureRecognizerD }, completion:nil) } - internal func continuousScroll() { + @objc internal func continuousScroll() { guard let fakeCell = cellFakeView else { return } let percentage = calcTriggerPercentage() @@ -360,7 +360,7 @@ open class RAReorderableLayout: UICollectionViewFlowLayout, UIGestureRecognizerD longPress?.delegate = self panGesture?.delegate = self panGesture?.maximumNumberOfTouches = 1 - let gestures: NSArray! = collectionView.gestureRecognizers as NSArray! + let gestures: NSArray! = collectionView.gestureRecognizers as NSArray? gestures.enumerateObjects(options: []) { gestureRecognizer, index, finish in if gestureRecognizer is UILongPressGestureRecognizer { (gestureRecognizer as AnyObject).require(toFail: self.longPress!) @@ -397,7 +397,7 @@ open class RAReorderableLayout: UICollectionViewFlowLayout, UIGestureRecognizerD } // long press gesture - internal func handleLongPress(_ longPress: UILongPressGestureRecognizer!) { + @objc internal func handleLongPress(_ longPress: UILongPressGestureRecognizer!) { let location = longPress.location(in: collectionView) var indexPath: IndexPath? = collectionView?.indexPathForItem(at: location) @@ -438,7 +438,7 @@ open class RAReorderableLayout: UICollectionViewFlowLayout, UIGestureRecognizerD } // pan gesture - func handlePanGesture(_ pan: UIPanGestureRecognizer!) { + @objc func handlePanGesture(_ pan: UIPanGestureRecognizer!) { panTranslation = pan.translation(in: collectionView!) if let cellFakeView = cellFakeView, let fakeCellCenter = fakeCellCenter, @@ -519,11 +519,11 @@ private class RACellFakeView: UIView { layer.shouldRasterize = false cellFakeImageView = UIImageView(frame: self.bounds) - cellFakeImageView?.contentMode = UIViewContentMode.scaleAspectFill + cellFakeImageView?.contentMode = UIView.ContentMode.scaleAspectFill cellFakeImageView?.autoresizingMask = [.flexibleWidth , .flexibleHeight] cellFakeHightedView = UIImageView(frame: self.bounds) - cellFakeHightedView?.contentMode = UIViewContentMode.scaleAspectFill + cellFakeHightedView?.contentMode = UIView.ContentMode.scaleAspectFill cellFakeHightedView?.autoresizingMask = [.flexibleWidth , .flexibleHeight] cell.isHighlighted = true @@ -562,7 +562,7 @@ private class RACellFakeView: UIView { shadowAnimation.fromValue = 0 shadowAnimation.toValue = 0.7 shadowAnimation.isRemovedOnCompletion = false - shadowAnimation.fillMode = kCAFillModeForwards + shadowAnimation.fillMode = CAMediaTimingFillMode.forwards self.layer.add(shadowAnimation, forKey: "applyShadow") }, completion: { _ in @@ -583,7 +583,7 @@ private class RACellFakeView: UIView { shadowAnimation.fromValue = 0.7 shadowAnimation.toValue = 0 shadowAnimation.isRemovedOnCompletion = false - shadowAnimation.fillMode = kCAFillModeForwards + shadowAnimation.fillMode = CAMediaTimingFillMode.forwards self.layer.add(shadowAnimation, forKey: "removeShadow") }, completion: { _ in