Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Example/MMCardView/SecondViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

import UIKit

protocol SecondViewProtocol {
protocol SecondViewProtocol : class{
func removeCard()
}
class SecondViewController: UIViewController {
var delegate:SecondViewProtocol?
weak var delegate:SecondViewProtocol?
override func viewDidLoad() {
super.viewDidLoad()

Expand Down
5 changes: 3 additions & 2 deletions Example/MMCardView/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@ class ViewController: UIViewController,CardCollectionViewDataSource {
let v = Int(arc4random_uniform(5))+1
c.imgV.image = UIImage.init(named: "image\(v)")
case let c as CardCCell:
c.clickCallBack {
c.clickCallBack{
[unowned self] in
if let vc = UIStoryboard.init(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "Second") as? SecondViewController {
vc.delegate = self
self.card.presentViewController(to: vc)
}
}
}
default:
return UICollectionViewCell()

Expand Down
2 changes: 1 addition & 1 deletion MMCardView/Classes/CardCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public protocol CardCellProtocol {
}

open class CardCell:UICollectionViewCell{
var collectionV:UICollectionView!
weak var collectionV:UICollectionView!
var reloadBlock:(()->Void)?
var customCardLayout:CardLayoutAttributes?
var originTouchY:CGFloat = 0.0
Expand Down
4 changes: 3 additions & 1 deletion MMCardView/Classes/CustomCardLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ class CustomCardLayout: UICollectionViewLayout {
self.collectionView?.performBatchUpdates({
self.collectionView?.reloadData()
}, completion: nil)
} get {
}
get {
return _selectIdx
}
}
Expand Down Expand Up @@ -141,6 +142,7 @@ class CustomCardLayout: UICollectionViewLayout {
attribute.frame = CGRect(x: currentFrame.origin.x, y: self.collectionView!.contentOffset.y, width: cellSize.width, height: cellSize.height)
} else if index < shitIdx-2 {
attribute.isHidden = true
attribute.frame = CGRect(x: currentFrame.origin.x, y: self.collectionView!.contentOffset.y, width: cellSize.width, height: cellSize.height)
}else {
attribute.frame = currentFrame
}
Expand Down
26 changes: 13 additions & 13 deletions MMCardView/Classes/CustomFlipTransition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,9 @@ enum TransitionMode: Int {
public class CustomFlipTransition: NSObject,UIViewControllerAnimatedTransitioning {
var duration = 0.3
var transitionMode:TransitionMode = .Present
var cardView:UICollectionViewCell!
weak var cardView:UICollectionViewCell!
weak var blurEffectView:UIVisualEffectView!
var originalCardFrame = CGRect.zero
lazy var blurView:UIVisualEffectView = {
let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.dark)
let blurEffectView = UIVisualEffectView(effect: blurEffect)
blurEffectView.alpha = 0.0
return blurEffectView
}()

public func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return duration
Expand All @@ -41,15 +36,20 @@ public class CustomFlipTransition: NSObject,UIViewControllerAnimatedTransitionin
toView?.frame = self.cardView.bounds
toView?.layer.cornerRadius = viewRadius
self.cardView.addSubview(toView!)
self.blurView.frame = containerView.bounds
self.blurView.alpha = 0.0
containerView.addSubview(self.blurView)

let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.dark)
let blurView = UIVisualEffectView(effect: blurEffect)
self.blurEffectView = blurView;

blurView.frame = containerView.bounds
blurView.alpha = 0.0
containerView.addSubview(blurView)

UIView.transition(with: self.cardView, duration: 0.7, options: [.transitionFlipFromRight,.curveEaseIn], animations: {
self.cardView.frame = CGRect.init(x: self.originalCardFrame.origin.x, y: self.originalCardFrame.origin.y, width: toViewF.width, height: toViewF.height)
}, completion: { (finish) in
UIView.animate(withDuration: 0.2, animations: {
self.blurView.alpha = 1.0
blurView.alpha = 1.0
})

toView?.frame = toViewF
Expand All @@ -68,10 +68,10 @@ public class CustomFlipTransition: NSObject,UIViewControllerAnimatedTransitionin
fromView?.frame = CGRect.init(x: fromView!.frame.origin.x, y: fromView!.frame.origin.y, width: self.originalCardFrame.width, height: self.originalCardFrame.height)
content.frame = CGRect.init(x: fromView!.frame.origin.x, y: fromView!.frame.origin.y, width: self.originalCardFrame.width, height: self.originalCardFrame.height)
self.cardView.frame = CGRect.init(x: 0, y: self.originalCardFrame.origin.y, width: self.originalCardFrame.width, height: self.originalCardFrame.height)
self.blurView.alpha = 0.0
self.blurEffectView.alpha = 0.0

}, completion: { (finish) in
self.blurView.removeFromSuperview()
self.blurEffectView.removeFromSuperview()
content.backgroundColor = originalCrolor
content.removeFromSuperview()
self.cardView.addSubview(content)
Expand Down