登录 立即注册
金钱:

【Swift】NHRangeSlider

来自: Torr 分类: iOS精品源码 上传时间: 2017-1-4 10:55:51
Tag:Slider 滑块 自定义 按钮 滑杆

项目介绍:

https://github.com/thehung111/NHRangeSlider

NHRangeSlider

A custom range slider in Swift. Forked from RangeSlider with some enhancements.

Swift中的自定义范围滑块。 增强版的 RangeSlider。

Requirements

  • iOS: 8.0+

  • Xcode 8.1+

  • Swift 3.0+

Installation

CocoaPods

CocoaPods 1.1.0+ is required to build NHRangeSlider.

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

target '<Your Target Name>' do
    pod 'NHRangeSlider', '~> 0.1.1'
end

Then, run the:

$ pod install

Carthage

Put the following in your Cartfile:

 github "thehung111/NHRangeSlider" ~> 0.1.1

Run carthage update --platform iOS --no-use-binaries

Usage 使用方法

Default Slider 默认

By default, the title label is not shown and the left and right thumbs will be circles (curvaceousness set to 1). You can add the view in code or via story board:

默认情况下,标题标签不显示,左右拇指将是圆圈(“curvaceousness”设置为1)。 您可以在代码或故事板中添加视图:

 override func viewDidLoad() {
    super.viewDidLoad()
    
    // default slider. Configure the frame
    let sliderView = NHRangeSliderView(frame: CGRect(x: 16, y: 20, width: self.view.bounds.width - 32, height: 80) )
    // call size to fit to resize the height to fit exactly
    sliderView.sizeToFit()
    self.view.addSubview(sliderView)

}

Slider with Square Thumbs 自定义

let sliderSquareView = NHRangeSliderView(frame: ...)

// set to 0 for square
sliderSquareView.curvaceousness = 0.0

sliderSquareView.trackHighlightTintColor = UIColor.red
sliderSquareView.lowerValue = 20.0
sliderSquareView.upperValue = 80.0
sliderSquareView.sizeToFit()
self.view.addSubview(sliderSquareView)

Slider with title

let sliderSquareWithLabelView = NHRangeSliderView(frame: ...)
sliderSquareWithLabelView.curvaceousness = 0.0
sliderSquareWithLabelView.trackHighlightTintColor = UIColor.brown
sliderSquareWithLabelView.lowerValue = 20.0
sliderSquareWithLabelView.upperValue = 80.0

// set title text
sliderSquareWithLabelView.titleLabel?.text = "Slider with title label"

sliderSquareWithLabelView.sizeToFit()
self.view.addSubview(sliderSquareWithLabelView)

Slider with labels following thumbs

let sliderWithLabelFollowView = NHRangeSliderView(frame: ...)
sliderWithLabelFollowView.trackHighlightTintColor = UIColor.black
sliderWithLabelFollowView.lowerValue = 30.0
sliderWithLabelFollowView.upperValue = 70.0
sliderWithLabelFollowView.gapBetweenThumbs = 5

// set style to follow
sliderWithLabelFollowView.thumbLabelStyle = .FOLLOW

sliderWithLabelFollowView.titleLabel?.text = "Slider with labels follow thumbs"
sliderWithLabelFollowView.sizeToFit()
self.view.addSubview(sliderWithLabelFollowView)

API Reference

https://thehung111.github.io/NHRangeSlider/

code4app

相关源码推荐:

我来说两句
*滑动验证:
所有评论(5)
hellokenken 2017-1-4 11:36:19
帮帮顶顶!!
回复
littleRed 2017-1-4 11:37:10
感谢分享,楼主V5~
回复
phoiu 2017-1-4 11:38:23
我是来学习的
回复
AlonMessi 2017-1-4 11:39:45
code4app确实是个好地方,必须支持~
回复
BlueManlove 2017-1-4 11:44:01
好好 学习了 确实不错
回复
kengsir 2017-1-4 11:46:12
不错不错,楼主辛苦了。。。
回复
code4app热心网友 2017-1-4 17:17:28
楼主用心了,内容非常精彩。
回复
code4app热心网友 2017-1-8 00:10:28
淡定,淡定,淡定……
回复
提取码:  下载次数:2 状态:已购或VIP 售价:0(原价:0)金钱 下载权限:初级码农 
86 0 2
代码贡献英雄榜
用户名 下载数
通过邮件订阅最新 Code4App 信息
上一条 /4 下一条
联系我们
关闭
合作电话:
13802416937
Email:
435399051@qq.com
商务市场合作/投稿
问题反馈及帮助
联系我们

广告投放| Github|申请友链|手机版|Code4App ( 粤ICP备15117877号-1 )

快速回复 返回顶部 返回列表