CircularStatesView 1.0

CircularStatesView 1.0

测试已测试
语言语言 SwiftSwift
许可 MIT
发布最新发布2016年5月
SPM支持 SPM

Or Elmaliah 维护。



CircularStatesView

CircularStatesView: Simple states view in Swift

使用 Swift 编写的自定义视图,允许您显示垂直的状态进度。当您在显示下一步操作的同时展示用户当前状态时非常方便。

演示

Demo

要求

Swift 2.2+

安装

使用方法

将其添加到 Storyboard/Code 中的子视图中。

override func viewDidLoad() {
    super.viewDidLoad()

    self.statesView.dataSource = self
    self.statesView.circleMaxSize = 80
    self.statesView.backgroundColor = UIColor.whiteColor()
    ...
}

然后使用 CircularStatesViewDataSource 协议

extension ViewController: CircularStatesViewDataSource {

    func numberOfStatesInCricularStatesView(cricularStatesView: CircularStatesView) -> Int {
        return 4
    }

    func cricularStatesView(cricularStatesView: CircularStatesView, isStateActiveAtIndex index: Int) -> Bool {
        return index <= self.myModelState
    }
    ...
}

属性

// The DataSource
public weak var dataSource: CircularStatesViewDataSource?

/// The number of states in view
public var numberOfStates: Int { get }

/// The circle's active state fill color
public var circleActiveColor: UIColor

/// The circle's in-active state fill color
public var circleInactiveColor: UIColor

/// The circle's border color
public var circleBorderColor: UIColor

/// The width of the border
public var circleBorderWidth: CGFloat

/// The circle size (diameter) is calculated using the view height and seperatorLength
public var circleSize: CGFloat { get }

/// Overrides the circle size calculation with a pre defined max size, min(calculatedSize(), circleMaxSize)
public var circleMaxSize: CGFloat?

/// The length of the seperator line between each circle state
public var seperatorLength: CGFloat

/// The line seperator color
public var seperatorColor: UIColor

/// The line seperator width
public var seperatorWidth: CGFloat

/// The states title font
public var stateTitleFont: UIFont

/// The color for the active title text label
public var titleLabelActiveTextColor: UIColor

/// The color for the inactive title text label
public var titleLabelInactiveTextColor: UIColor

/// The index for the state with activity indicator
public var indexForStateWithActivityIndicator: Int?

/// The color for the activity indicator
public var stateActivityIndicatorColor: UIColor

方法

DataSource reloadData

func reloadData()

协议

数据源协议

public protocol CircularStatesViewDataSource: class {
    /**
     Return the number of states in the view
     - parameter circularStatesView: The CircularStatesView
     - returns: The number of states
     */
    func numberOfStatesInCircularStatesView(circularStatesView: CircularStatesView) -> Int

    /**
     Return whether the state at index is active or inactive
     - parameter circularStatesView: The CircularStatesView
     - parameter index: The state index
     - returns: true/false for active/inactive state
     */
    func circularStatesView(circularStatesView: CircularStatesView, isStateActiveAtIndex index: Int) -> Bool

    /**
     Return the title string for the state, this title we'll be displayed along side the state
     - parameter circularStatesView: The CircularStatesView
     - parameter index: The state index
     - returns: title string or nil if you don't need a title for the specific state
     */
    func circularStatesView(circularStatesView: CircularStatesView, titleForStateAtIndex index: Int) -> String?

    /**
     Return image icon for active state, this icon will be shown in the circle center
     - parameter circularStatesView: The CircularStatesView
     - parameter index: The state index
     - returns: UIImage for the image icon or nil if you don't want to show an icon
     */
    func circularStatesView(circularStatesView: CircularStatesView, imageIconForActiveStateAtIndex index: Int) -> UIImage?

    /**
     Return image icon for inactive state, this icon will be shown in the circle center
     - parameter circularStatesView: The CircularStatesView
     - parameter index: The state index
     - returns: UIImage for the image icon or nil if you don't want to show an icon
     */
    func circularStatesView(circularStatesView: CircularStatesView, imageIconForInActiveStateAtIndex index: Int) -> UIImage?
}

作者

CircularStatesView 由 Or Elmaliah 所有并维护。您可以在 Twitter 上关注我 @OrElm

待办事项

  • [ ] 将可选标题标签添加到状态圆圈中心(将优先级设置为什么?图像还是标题?)
  • [x] 添加标题标签
  • [x] 添加状态图像图标
  • [x] 所有容器居中
  • [x] 将自定义视图添加到圆圈中(例如活动指示器视图)
  • [x] 为状态添加水波纹效果
  • [x] 支持界面方向
  • [x] 支持Interface Orientations
  • [ ] 完成文档
  • [ ] 彻底删除调试 Pod
  • [x] 支持Cocoapods

MIT 许可证

版权所有 © 2016 Or Elmaliah

以下条件下,授予任何获取此软件及其相关文档文件(“软件”)副本的个人免费使用软件的权利,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件副本,并准许获得软件副本的个人进行此类使用:

应包含上述版权声明和本许可声明在内的软件的所有副本或主要内容。

本软件按“原样”提供,不提供任何形式的质量保证,无论是明示还是暗示,包括但不限于对适销性、特定用途适用性和非侵权的保证。在任何情况下,作者或版权所有者都不得对任何索赔、损害或其他责任承担责任,无论其性质为何,也不论是否因合同、侵权或其他原因而引起,并与其产生的软件或软件的使用、销售或其他施加有任何联系。