• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

cemolcay/MaterialCardView: Create material design cards quick and easy

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

cemolcay/MaterialCardView

开源软件地址(OpenSource Url):

https://github.com/cemolcay/MaterialCardView

开源编程语言(OpenSource Language):

Swift 91.0%

开源软件介绍(OpenSource Introduction):

MaterialCardView

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




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap