RappleColorPicker 3.0.3

RappleColorPicker 3.0.3

测试已测试
Lang语言 SwiftSwift
许可证 MIT
发布最后发布2017年12月
SwiftSwift 版本4.0
SPM支持 SPM

Rapple UI Animator 维护。



  • Rajeev Prasad

RappleColorPicker

要求

  • Xcode 8
  • Swift 3
  • iOS 8+

示例应用

要运行示例项目,请克隆仓库,然后首先从 Example 目录中运行 pod install

安装

RappleColorPicker 通过 CocoaPods 提供。安装它,只需将以下行添加到您的 Podfile 中

pod "RappleColorPicker"

首先在 Swift 类中导入颜色选择器 Pod

import RappleColorPicker

打开颜色调板所需的参数

  • onViewController 打开颜色调板的视图控制器 - 此参数不能为 nil
  • origin 颜色调板的起点 - 默认:CGPoint.zero
  • delegate RappleColorPickerDelegate
  • title 颜色调板名称,发送 nil 隐藏标题栏
  • tag 识别标签
  • attributes 外观和感觉属性字典(标题、BGColor、TintColor、Style、BorderColor)

attribute 字典应在 RappleCPAttributeKey 枚举中查找到这些键值。如果无法找到任何键,则默认值将用于创建 UI

enum RappleCPAttributeKey {
    case Title          `Title text - attributes without Title will hide title bar from UI`
    case BGColor        `Background color`
    case Style          `Cell style (Square, Circle)`
    case TintColor      `TintColor Tint Color (Text color, cell border color)`
    case BorderColor    `Color pallet border Color (Complete pallet border)`
}

Style 键必须具有以下风格之一

  • RappleCPStyleSquare // 方形颜色选择器单元格
  • RappleCPStyleCircle // 圆形颜色选择器单元格

默认选择器大小 - 230x358(不带标题)或 230x384(带标题)

  • 以默认外观和感觉打开颜色选择器
RappleColorPicker.openColorPallet(onViewController: self, origin: origin, delegate: self, title: "title")
  • 以标签和默认外观和感觉打开颜色选择器
RappleColorPicker.openColorPallet(onViewController: self, origin: origin, delegate: self, title: "title", tag: 1)
  • 以自定义外观和感觉打开颜色选择器(可选)。
RappleColorPicker.openColorPallet(onViewController: self, origin: origin, delegate: self, attributes: attributes)
  • 以标签和自定义外观和感觉打开颜色选择器(可选)
RappleColorPicker.openColorPallet(onViewController: self, origin: origin, delegate: self, attributes: attributes, tag: 1)

要接收选中的颜色,实现 'RappleColorPickerDelegate' 中的一个委托。

func colorSelected(color: UIColor) {
    RappleColorPicker.close()
}

func colorSelected(color:UIColor, tag: Int) {
    switch (tag) {
        case 1: `set tag one color`
        case 2: `set tag two color`
        default: ()
    }
    RappleColorPicker.close()
}

如果两个都实现了,则优先考虑 func colorSelected(color:UIColor, tag: Int) 方法,而 func colorSelected(color: UIColor) 方法将不会调用

  • 要关闭颜色选择器
RappleColorPicker.close()

演示

demo

示例项目

要运行示例项目,请克隆仓库,然后首先从 Example 目录中运行 pod install

作者

Rajeev Prasad,

许可

版权© 2016 Rajeev Prasad

在此特此授权,免费提供给任何获得此软件及其相关文档副本(“软件”)的个人,在不受限制的情况下处理软件,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件副本的权利,并允许向软件提供副本的个人执行此操作,但须遵守以下条件

上述版权声明和本许可证通知应当包含在软件的所有副本或大部分副本中。

软件按“原样”提供,没有任何形式的保证,明示或暗示,包括但不限于适用性、特定目的的适用性和非侵权性。在任何情况下,作者或版权所有者均不对任何索赔、损害或其他责任(无论基于合同行为、侵权或其他行为)负责,这些索赔、损害或其他责任源于、由于或与软件或使用软件或任何其他交易有关。