Skip to content

Commit 9791f44

Browse files
committed
Sorry, I was confused with three branches. I am a little afraid to use merge for now.
1 parent 4f82e23 commit 9791f44

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

Classes/Extension/UICollectionViewControllerExtension.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import UIKit
1111
import ObjectiveC
1212

1313
private var selectedIndexPathAssociationKey: UInt8 = 0
14-
private var areaRectInSuperviewKey: UInt8 = 1
14+
private var coverRectInSuperviewKey: UInt8 = 1
1515

1616
extension UICollectionViewController {
1717

@@ -24,15 +24,15 @@ extension UICollectionViewController {
2424
}
2525
}
2626

27-
var areaRectInSuperview: CGRect! {
27+
var coverRectInSuperview: CGRect! {
2828
get {
29-
let value = objc_getAssociatedObject(self, &areaRectInSuperviewKey) as? NSValue
29+
let value = objc_getAssociatedObject(self, &coverRectInSuperviewKey) as? NSValue
3030
return value?.CGRectValue()
3131
}
3232

3333
set(newValue){
3434
let value = NSValue(CGRect: newValue)
35-
objc_setAssociatedObject(self, &areaRectInSuperviewKey, value, .OBJC_ASSOCIATION_RETAIN)
35+
objc_setAssociatedObject(self, &coverRectInSuperviewKey, value, .OBJC_ASSOCIATION_RETAIN)
3636
}
3737
}
3838

Classes/SDEPushAndPopAnimationController.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class SDEPushAndPopAnimationController: NSObject, UIViewControllerAnimatedTransi
4949

5050
let layoutAttributes = fromVC!.collectionView?.layoutAttributesForItemAtIndexPath(fromVC!.selectedIndexPath)
5151
let areaRect = fromVC!.collectionView?.convertRect(layoutAttributes!.frame, toView: fromVC!.collectionView?.superview)
52-
toVC!.areaRectInSuperview = areaRect!
52+
toVC!.coverRectInSuperview = areaRect!
5353

5454
//key code, the most important code here. without this line, you can't get visibleCells from UICollectionView.
5555
//And, there are other ways, Just make view redraw.
@@ -113,7 +113,7 @@ class SDEPushAndPopAnimationController: NSObject, UIViewControllerAnimatedTransi
113113
coverContainerView.tag = 1000
114114

115115
toVC.view.addSubview(coverContainerView)
116-
coverContainerView.frame = toVC.areaRectInSuperview
116+
coverContainerView.frame = toVC.coverRectInSuperview
117117

118118
let frame = coverContainerView.frame
119119
coverContainerView.layer.anchorPoint = CGPointMake(0, 0.5)
@@ -187,7 +187,7 @@ class SDEPushAndPopAnimationController: NSObject, UIViewControllerAnimatedTransi
187187
private func setupVisibleCellsBeforePushToVC(toVC:UICollectionViewController){
188188
if toVC.collectionView?.visibleCells().count > 0{
189189

190-
let areaRect = toVC.collectionView!.convertRect(toVC.areaRectInSuperview, fromView: toVC.collectionView!.superview)
190+
let areaRect = toVC.collectionView!.convertRect(toVC.coverRectInSuperview, fromView: toVC.collectionView!.superview)
191191
let cellsAreaRect = UIEdgeInsetsInsetRect(areaRect, coverEdgeInSets)
192192

193193
let cellWidth = (cellsAreaRect.width - CGFloat(horizontalCount - 1) * horizontalGap) / CGFloat(horizontalCount)
@@ -249,7 +249,7 @@ class SDEPushAndPopAnimationController: NSObject, UIViewControllerAnimatedTransi
249249
let minimalRow = rows.reduce(Int.max, combine: { $0 < $1 ? $0 : $1 })
250250

251251
let collectionView = fromVC.collectionView!
252-
let areaRect = collectionView.convertRect(fromVC.areaRectInSuperview, fromView: fromVC.collectionView!.superview)
252+
let areaRect = collectionView.convertRect(fromVC.coverRectInSuperview, fromView: fromVC.collectionView!.superview)
253253
let cellsAreaRect = UIEdgeInsetsInsetRect(areaRect, coverEdgeInSets)
254254

255255
let cellWidth = (cellsAreaRect.width - CGFloat(horizontalCount - 1) * horizontalGap) / CGFloat(horizontalCount)

0 commit comments

Comments
 (0)