Cusom CollectionView card layout

Related tags

Cards MMCardView
Overview

MMCardView

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Demo

1.Card

demo

Requirements

iOS 8.0+
Xcode 8.0+
Swift 3.0+

Use Card

1.Inherit your collectionView to MMCollectionView

@IBOutlet weak var cardCollection: MMCollectionView!

2.Create your Cell inherit "CardCell"

class CardACell: CardCell {

}

if let layout = cardCollection.collectionViewLayout as? CustomCardLayout {
     layout.titleHeight = 100.0
     layout.bottomShowCount = 3
     layout.cardHeight = 300
     layout.showStyle = .cover
}

Installation

MMCardView is available through CocoaPods. To install it, simply add the following line to your Podfile:

Swift 3
pod 'MMCardView'
Swift2.3
pod 'MMCardView',:git => 'https://github.com/MillmanY/MMCardView', :branch => ‘Swift2’

Author

Millman, [email protected]

License

MMCardView is available under the MIT license. See the LICENSE file for more info.

Comments
  • Override default card height

    Override default card height

    Is there an API or a best practice to override default card height? The UI I have in mind is one that mimics Apple pay where cards are smaller.

    Thanks,

    opened by mxw39 1
  • How can i have section header?

    How can i have section header?

    I have tried to setup a section header using UICollectionReusableView. but, it is not showing up. Is there any way to achieve a section header with this library?

    opened by Dhavalbhimani007 0
  • Reloading items when scrolling.

    Reloading items when scrolling.

    We are trying to display images from network in cell items. Our images were blinking simultaneously when scrolling MMCollectionView.

    NumberOfItemsInSection method is keep calling when scroll the items. Why this is happening?

    Pls suggest to solve this issue asap.

    Thanks

    opened by KanagarajPonnusamy 0
  • set(cards:)  need DispatchQueue.main.async

    set(cards:) need DispatchQueue.main.async

    This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes.

    opened by huhuegg 0
  • Filtering is not working properly

    Filtering is not working properly

    I altered some things in your example ViewController.swift to give you the perspective I'm facing, those were the changes:

    var titleArray = ["GIOVANNIJ","MARCO","IBITCI","GOD","DID","RUAN","APPEND","BIAJ","LELE","TETE"]
    
    func generateCardInfo (cardCount:Int) -> [AnyObject] {
        var arr = [AnyObject]()
        let xibName = ["CardA"]//,"CardB","CardC"]
        
        for _ in 1...cardCount {
            let value = Int(arc4random_uniform(UInt32(xibName.count)))
            arr.append(xibName[value] as AnyObject)
        }
    
        return arr
    }
    
    func cardView(collectionView:UICollectionView,item:AnyObject,indexPath:IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: item as! String, for: indexPath )
        switch cell {
            case let c as CardACell:
                c.txtView.text = "Hello This is MMCardView ,Its a demo with different Card Type,This is a text type"
            
                c.labTitle.text = titleArray[indexPath.row]
            
            case let c as CardBCell:
                let v = Int(arc4random_uniform(5))+1
                c.imgV.image = UIImage.init(named: "image\(v)")            
            case let c as CardCCell:
                c.clickCallBack {
                    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()
    
        }
        return cell
    }
    
    @IBAction func filterAction () {
        let sheet = UIAlertController.init(title: "Filter", message: "Select you want to show in View", preferredStyle: .alert)
    
        sheet.addTextField(configurationHandler: nil)
        
        
        
        let byText = UIAlertAction(title: "Filter by text", style: .default, handler: {
            (alert: UIAlertAction!) -> Void in
            self.card.filterAllDataWith(isInclued: { (idex, obj) -> Bool in
                let titleTxt = self.titleArray[idex]
                return titleTxt.lowercased().contains(sheet.textFields![0].text!)
            })
        })
        
        /*let cellA = UIAlertAction(title: "CellA", style: .default, handler: {
            (alert: UIAlertAction!) -> Void in
            self.card.filterAllDataWith(isInclued: { (idex, obj) -> Bool in
                return (obj as! String) == "CardA"
            })
        })
        
        let cellB = UIAlertAction(title: "CellB", style: .default, handler: {
            (alert: UIAlertAction!) -> Void in
            
            self.card.filterAllDataWith(isInclued: { (idex, obj) -> Bool in
                return (obj as! String) == "CardB"
            })
        })
        
        let cellC = UIAlertAction(title: "CellC", style: .default, handler: {
            (alert: UIAlertAction!) -> Void in
            self.card.filterAllDataWith(isInclued: { (idex, obj) -> Bool in
                return (obj as! String) == "CardC"
            })
        })
        let ac = ["CardA","CardC"]
        let cellAC = UIAlertAction(title: "CellA,CellC", style: .default, handler: {
            (alert: UIAlertAction!) -> Void in
            
            
            self.card.filterAllDataWith(isInclued: { (idex, obj) -> Bool in
                return ac.contains(obj as! String)
            })
        })*/
        
        let allCell = UIAlertAction(title: "Show all cells", style: .default, handler: {
            (alert: UIAlertAction!) -> Void in
           self.card.showAllData()
        })
        let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: {
            (alert: UIAlertAction!) -> Void in
        })
                
        //sheet.addAction(cellA)
        sheet.addAction(byText)
        /*sheet.addAction(cellB)
        sheet.addAction(cellC)
        sheet.addAction(cellAC)*/
    
        sheet.addAction(allCell)
        sheet.addAction(cancelAction)
        self.present(sheet, animated: true, completion: nil)
    }
    

    Now this is what I'm facing:

    1. You have a pile of the same type cards differentiating them only by some sort of text (all of these are stored in an array).
    2. You choose to filter those cards by some text, looking for the cards that contains that text you typed.
    3. The filtering is done properly.
    4. You choose to show all your cards, to go back to the original state.
    5. Apparently everything is okay, but some cards are duplicated and some are missing.

    Can you help me with this?

    opened by gask 2
  • Issue with Card View Not Showing

    Issue with Card View Not Showing

    Hi,

    Thank you for sharing the card view it looks very good. I'm having trouble to get the example working (I'm using Materials as well) card view is not showing. I did try to isolate and see if it is related to the cell, but if i just show the cell they will show in view. I'm doing it without storyboard. I'm not sure if i would be the cause of the problem. Only the first few lines of the code from example I changed just so that I can figure out why its not showing. However, I still couldn't figure out. It looks like objects were initiated under the card view, but the card view is not showing.

    var card = CardView(frame: CGRect(x: 100, y: 200, width: 500, height: 500))
    
    open override func viewDidLoad() {
        
        super.viewDidLoad()
        
        self.card.frame  = CGRect(x: 100, y: 200, width: 500, height: 500)
        self.card.backgroundColor = UIColor.red
        
        view.addSubview(self.card)
         self.card.cardDataSource = self
        self.card.registerCardCell(c: CardACell.classForCoder(), nib: UINib.init(nibName: "CardACell", bundle: Bundle.main))
       
        prepareToolbar()
        let arr = self.generateCardInfo(cardCount: 10)
        self.card.set(cards: arr)
        
        
    
        self.card.showStyle(style: .cover)
        //view.layout(card).horizontally().center()
        
        view.backgroundColor = UIColor.purple
        
       
    }
    
    opened by winniepooh001 0
Owner
Millman Yang
Millman Yang
Swipe able, customizable card stack view, Tinder like card stack view based on UICollectionView. Cards UI

Swipable, customizable card stack view, Tinder like card stack view based on UICollectionView. Cards UI Сocoapods installation Add in your Podfile: po

Indy 850 Nov 17, 2022
IOS Card Game - A simple card game using SwiftUI

IOS_Card_Game A simple card game using Swift UI.

Md. Masum Musfique 1 Mar 25, 2022
A reactive, card-based UI framework built on UIKit for iOS developers.

CardParts - made with ❤️ by Intuit: Example Requirements Installation Communication & Contribution Overview Quick Start Architecture CardsViewControll

Intuit 2.5k Jan 4, 2023
A SwiftUI based custom sheet card to show information in iOS application.

A SwiftUI based custom sheet card to show any custom view inside the card in iOS application.

Mahmud Ahsan 4 Mar 28, 2022
A SwiftUI card view, made great for setup interactions.

SlideOverCard A SwiftUI card design, similar to the one used by Apple in HomeKit, AirPods, Apple Card and AirTag setup, NFC scanning, Wi-Fi password s

João Gabriel 716 Dec 29, 2022
This UI attempts to capture the Quibi Card Stack and the associated User Interaction.

RGStack This UI attempts to capture the Quibi Card Stack and the associated User Interaction. Required A View that conforms to the ConfigurableCard pr

RGeleta 96 Dec 18, 2022
Card-based view controller for apps that display content cards with accompanying maps, similar to Apple Maps.

TripGo Card View Controller This is a repo for providing the card-based design for TripGo as well as the TripKitUI SDK by SkedGo. Specs 1. Basic funct

SkedGo 6 Oct 15, 2022
Card flip animation by pan gesture.

CardAnimation Design from Dribble. 实现思路在这里。 Two Solutions At the begin, I didn't encapsulate code, @luxorules refactor code into class and improve it

null 1.2k Dec 14, 2022
Awesome looking Dial like card selection ViewController

KVCardSelectionVC Awesome looking Dial like card selection ViewController An updated Swift 3 working version of : https://github.com/atljeremy/JFCardS

Kunal Verma 23 Feb 1, 2021
🃏 Tinder like card interface

Features Swift 3 Custom views for the card & overlay Generic Dynamically add new cards on top or on the bottom Lazy view loading Setup pod 'DMSwipeCar

Dylan Marriott 250 Nov 15, 2022
🔥 A multi-directional card swiping library inspired by Tinder

Made with ❤️ by Mac Gallagher Features ?? Advanced swipe recognition based on velocity and card position ?? Manual and programmatic actions ?? Smooth

Mac Gallagher 754 Dec 28, 2022
An iOS library to create beautiful card transitions.

CSCardTransition CSCardTransition is a small library allowing you to create wonderful push and pop transition animations like in the App Store. It wor

Creastel 5 Jan 14, 2022
SimpleCardView-SwiftUI is a very simple card view written with SwiftUI

SimpleCardView-SwiftUI is a very simple card view written with SwiftUI

Tomortec 3 May 19, 2022
GLScratchCard - Scratch card effect

I loved the way payments app's like Google pay and PhonePe used scratch card option to reward it's user. Hence with ?? cloned the same scratch card effect for you guys out there

Gokul 84 Dec 5, 2022
:star: Custom card-designed CollectionView layout

CardsLayout CardsLayout is a lightweight Collection Layout. Installation CocoaPods You can use CocoaPods to install CardsLayout by adding it to your P

Filipp Fediakov 798 Dec 28, 2022
A CollectionView Layout displaying a slanted cells

CollectionViewSlantedLayout is a subclass of the UICollectionViewLayout allowing the display of slanted cells in a UICollectionView. Features Pure Swi

Yassir Barchi 2.2k Dec 27, 2022
A CollectionView Layout displaying a slanted cells

CollectionViewSlantedLayout is a subclass of the UICollectionViewLayout allowing the display of slanted cells in a UICollectionView. Features Pure Swi

Yassir Barchi 2.2k Dec 27, 2022
card.io provides fast, easy credit card scanning in mobile apps

card.io SDK for iOS card.io provides fast, easy credit card scanning in mobile apps. NEW!!! card.io is now an open-source project! As of December 2014

card.io 2.3k Jan 4, 2023
Swipe able, customizable card stack view, Tinder like card stack view based on UICollectionView. Cards UI

Swipable, customizable card stack view, Tinder like card stack view based on UICollectionView. Cards UI Сocoapods installation Add in your Podfile: po

Indy 850 Nov 17, 2022
Ios-card-transition - iOS CocoaPod to create beautiful card transitions

CSCardTransition CSCardTransition is a small library allowing you to create wond

Creastel 12 Oct 31, 2022