SectionedSlider 0.0.5

SectionedSlider 0.0.5

测试已测试
语言语言 SwiftSwift
许可协议 MIT
发布最后发布2018年4月
SPM支持 Swift Package Manager

Leonardo Cardoso 维护。



SectionedSlider

iOS watchOS

Platform CocoaPods Carthage Compatible

控制中心滑块

要求

  • iOS 8.0+
  • Swift 3.0+
  • Xcode 8.0+

安装

CocoaPods

CocoaPods 是 Cocoa 项目的依赖管理器。您可以使用以下命令安装它

$ gem install cocoapods

要构建 SectionedSlider 0.0.5+,需要 CocoaPods 1.1.0+。

使用 CocoaPods 将 SectionedSlider 集成到 Xcode 项目中,请在 Podfile 中指定它

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'SectionedSlider', '~> 0.0.5'

然后,运行以下命令

$ pod install

Carthage

Carthage 是一个去中心化的依赖管理器,它自动处理向您的 Cocoa 应用添加框架的过程。

您可以使用以下命令通过 Homebrew 安装 Carthage

$ brew update
$ brew install carthage

要使用 Carthage 将 SectionedSlider 集成到您的 Xcode 项目中,请在您的 Cartfile 中指定它

github "LeonardoCardoso/SectionedSlider" ~> 0.0.5

手动方式

如果您不希望使用上述依赖管理器之一,您可以手动将 SectionedSlider 集成到项目中。

用法

您可以在 Storyboard 中使用 SectionedSlider,或者如果您想以编程方式执行此操作,可以像创建 UIView 一样创建它。

SectionedSlider(
    frame: CGRect(x: 0, y: 0, width: 78, height: 200), // Choose a 15.6 / 40 ration for width/height
    selectedSection: 3, // Initial selected section
    sections: 10 // Number of sections. Choose between 2 and 20
)

调色板

您还可以在其构造函数中自定义按钮的颜色。

SectionedSlider(
    frame: wrapView.frame,
    selectedSection: 3,
    sections: 10,
    palette: Palette(
        viewBackgroundColor: UIColor?,
        sliderBackgroundColor: UIColor?,
        sliderColor: UIColor?
    )
)

palette

委托

通过实现该协议,您可以监视状态的更改

public protocol SectionedSliderDelegate {
    
	func sectionChanged(slider: SectionedSlider, selected: Int)
    
}

Storyboard

最后但同样重要的是,您可以直接从 Interface Builder 或 Storyboard 定制 SectionedSlider 属性。

storyboard

许可

SectionedSlider以MIT许可发布。详细信息请参阅LICENSE