MaterialKit 0.4

MaterialKit 0.4

测试测试
语言语言 SwiftSwift
许可证 MIT
发布最后发布2016年3月
SPM支持 SPM

nghialv 维护。




MaterialKit

Swift 编写的 Material design 组件(受 Google Material Design 启发)用于 iOS

请随时提交 pull request。

特性

  • 高度可定制
  • 完整的示例
  • 支持 @IBDesignable,在 Interface Builder 中实时渲染组件
  • 通过支持 @IBInspectable,类属性可以在 Interface Builder 中暴露,并且您可以实时编辑这些属性

  • [x] MKButton: 浮动操作按钮,提升按钮,平面按钮,水波纹效果

  • [x] MKTextField: 水波纹效果,浮动占位符
  • [x] MKTableViewCell
  • [x] MKLabel
  • [x] MKImageView
  • [x] MKLayer
  • [x] MKColor
  • [x] MKActivityIndicator
  • [x] MKRefreshControl
  • [x] MKNavigationBar

组件

MKButton

  • 主要有三种按钮类型:浮动操作按钮提升按钮平面按钮
  • 可定制属性:颜色、水波纹位置、动画时间函数、动画持续时间……
let button = MKButton(frame: CGRect(x: 10, y: 10, width: 100, height: 35))
button.maskEnabled = true
button.rippleLocation = .TapLocation
button.rippleLayerColor = UIColor.MKColor.LightGreen

MKTextField

  • 单行文本字段
  • 浮动占位符
  • 水波纹动画
  • 可定制属性:颜色、水波纹位置、底部边框、动画时间函数、动画持续时间……
textField.rippleLocation = .Left
textField.floatingPlaceholderEnabled = true
textField.placeholder = "Description"
textField.layer.borderColor = UIColor.MKColor.Green.CGColor
textField.rippleLayerColor = UIColor.MKColor.LightGreen

MKTableViewCell

  • 可定制属性:颜色、水波纹位置、动画时间函数、动画持续时间……
var cell = tableView.dequeueReusableCellWithIdentifier("MyCell") as MyCell
cell.rippleLocation = .Center
cell.rippleLayerColor = UIColor.MKColor.Blue

MKRefreshControl

  • 可定制属性:颜色、高度
var refreshControl = MKRefreshControl()
refreshControl.addToScrollView(self.tableView, withRefreshBlock: { () -> Void in
    self.tableViewRefresh()
})
refreshControl.beginRefreshing()

MKImageView (BarButtonItem),MKActivityIndicator

  • 可定制属性:颜色、水波纹位置、动画时间函数、动画持续时间……
  • 通过调用 animateRipple 方法或设置 userInteractionEnabled = true,您可以在需要时播放水波纹动画,当标签/图片视图被点击时,会播放水波纹动画

  • 通过使用 MKLabel 或 MKImageView,便于自定义 UIBarButtonItem 或 UITabBarButton

// customize UIBarButtonItem by using MKImageView
let imgView = MKImageView(frame: CGRect(x: 0, y: 0, width: 44, height: 32))
imgView.image = UIImage(named: "uibaritem_icon.png")
imgView.rippleLocation = .Center
imgView.userInteractionEnabled = true

let rightBarButton = UIBarButtonItem(customView: imgView)
self.navigationItem.rightBarButtonItem = rightBarButton

MKLayer

CALayer 的子类。

MKColor

一个用于UIColor的类别,增加了获取由Google设计的平面色值的几个方法

// get color from UIColor
let lightBlueColor = UIColor.MKColor.LightBlue

MKNavigationBar

一个自定义的UINavigationBar,支持提升效果和在自身上方添加色调

  • 可定制属性:颜色、暗色、提升效果、阴影透明度、色调颜色…
  • 在Storyboard设计中将导航栏的类设置为MKNavigationBar,并设置自定义属性

MKSwitch

开关切换单个设置选项的状态。开关控制的选项及其状态应从相应的行内标签中清晰可见。开关具有与单选按钮相同的视觉属性。

安装

  • 使用CocoaPods安装
    pod 'MaterialKit', :git => 'https://github.com/rahuliyer95/MaterialKit.git'
  • 将所有文件复制到您的项目中
  • 使用子模块

要求

  • iOS 8.0+
  • Xcode 6.1

许可

MaterialKit在MIT许可下发布。有关详细信息,请参阅LICENSE。