Latest 0.0.2
Homepage https://github.com/cemolcay/MaterialCardView
License MIT
Platforms ios 8.0, requires ARC
Authors

Create material design cards quick and easy

Demo

alt tag

Installation

Manuel

Copy & paste MaterialCardView.swift and CEMKit.swift to your project

CocoaPods

Add to your podfile

    pod 'MaterialCardView', '~> 0.0.2'

Usage

Create a MaterialCardView

    let c = MaterialCardView (
                   x: 10,
                   y: StatusBarHeight + 10,
                   w: ScreenWidth-20)  
    view.addSubview (c)

And start to add MaterialCardCells

  • Header Cell
    func addHeader (title: String)
    func addHeader (view: UIView)
  • Cell
    addCell (text: String, action: (()->Void)? = nil)
    addCell (view: UIView, action: (()->Void)? = nil)
    addCell (cell: MaterialCardCell)
  • FooterCell
    func addFooter (title: String)
    func addFooter (view: UIView)

Material Card will update its frame size when you add or
remove MaterialCardCells.
This is why you don’t set its height value when initilize it.

MaterialCardAppearance

    var headerBackgroundColor: UIColor
    var cellBackgroundColor: UIColor
    var borderColor: UIColor

    var titleFont: UIFont
    var titleColor: UIColor

    var textFont: UIFont
    var textColor: UIColor

    var shadowColor: UIColor
    var rippleColor: UIColor
    var rippleDuration: NSTimeInterval

You can change MaterialCardView appearance by its appearance property.

The default appearance is

    func defaultAppearance () -> MaterialCardAppearance {
        return MaterialCardAppearance (
            headerBackgroundColor: UIColor.CardHeaderColor(),
            cellBackgroundColor: UIColor.CardCellColor(),
            borderColor: UIColor.CardBorderColor(),
            titleFont: UIFont.TitleFont(),
            titleColor: UIColor.TitleColor(),
            textFont: UIFont.TextFont(),
            textColor: UIColor.TextColor(),
            shadowColor: UIColor.ShadowColor(),
            rippleColor: UIColor.RippleColor(),
            rippleDuration: rippleDuration)
    }

Which are UIColor and UIFont extensions defined at top of MaterialCardView.swift file.

MaterialAnimationTimingFunction

    enum MaterialAnimationTimingFunction {
        case SwiftEnterInOut
        case SwiftExitInOut

        func timingFunction () -> CAMediaTimingFunction {
            switch self {

            case .SwiftEnterInOut:
                return CAMediaTimingFunction (controlPoints: 0.4027, 0, 0.1, 1)

            case .SwiftExitInOut:
                return CAMediaTimingFunction (controlPoints: 0.4027, 0, 0.2256, 1)
            }
        }
    }

SwiftEnterInOut

(0.4027, 0, 0.1, 1)

SwiftExitInOut

(0.4027, 0, 0.2256, 1)

MaterialRippleLocation

enum MaterialRippleLocation {
    case Center
    case TouchLocation
}

RippleLayer

Adds ripple animation when you add cells with action
    c.addCell("Item 1") { sender in
        println("item 1 tapped")
    }

alt tag

Add ripple to material card
     c.addRipple { () -> Void in
       println("all card ripples")
   }

alt tag

Latest podspec

{
    "name": "MaterialCardView",
    "version": "0.0.2",
    "summary": "Create material design cards quick and easy.",
    "description": "  Create a `MaterialCardView`nn  ``` swiftn  let c = MaterialCardView (n  x: 10,n  y: StatusBarHeight + 10,n  w: ScreenWidth-20)n  view.addSubview (c)n  ```nn  And start to add `MaterialCardCell`snn  * Header Cellnn  ``` swiftn  func addHeader (title: String)n  func addHeader (view: UIView)n  ```nn  * Cellnn  ``` swiftn  addCell (text: String, action: (()->Void)? = nil)n  addCell (view: UIView, action: (()->Void)? = nil)n  addCell (cell: MaterialCardCell)n  ```nn  * FooterCellnn  ``` swiftn  func addFooter (title: String)n  func addFooter (view: UIView)n  ```nnn  >Material Card will update its frame size when you add orn  >remove `MaterialCardCell`s.n  >This is why you don't set its `height` value when initilize it.nn",
    "homepage": "https://github.com/cemolcay/MaterialCardView",
    "license": "MIT",
    "authors": {
        "Cem Olcay": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/cemolcay/MaterialCardView.git",
        "tag": "v0.0.2"
    },
    "source_files": [
        "MaterialCardView/MaterialCardView.swift",
        "MaterialCardView/CEMKit.swift"
    ],
    "requires_arc": true
}

Pin It on Pinterest

Share This