Latest 1.0.2
Homepage https://github.com/danjiang/DTRuler
License MIT
Platforms ios 8.4, requires ARC
Authors

Swift
Platform
CocoaPods
Carthage compatible

Introduction

Simple ruler input control.

Demo

Installation

Requirement

iOS 8.4+

CocoaPods

To install DTRuler add a dependency to your Podfile:

pod "DTRuler"

Carthage

To install DTRuler add a dependency to your Cartfile:

github "danjiang/DTRuler"
carthage update --platform ios

Usage

Import

import DTRuler

Use

// Float with step as 0.1
let scale = 78.9
let ruler = DTRuler(scale: .float(scale), minScale: .float(9), maxScale: .float(999), width: view.bounds.width - 50)

// or Integer with step as 1
let scale = 59
let ruler = DTRuler(scale: .integer(scale), minScale: .integer(10), maxScale: .integer(100), width: view.bounds.width - 50)

ruler.delegate = self

extension ViewController: DTRulerDelegate {

  func didChange(on ruler: DTRuler, withScale scale: DTRuler.Scale) {
    switch scale {
    case .float(let f):
      print(f)
    case .integer(let i):
      print(i)
  }

}

Customize

struct Colorful: DTRulerTheme {

  var backgroundColor: UIColor {
    return UIColor.lightGray
  }

  var pointerColor: UIColor {
      return UIColor.gray
  }

  var majorScaleColor: UIColor {
    return UIColor.darkGray
  }

  var minorScaleColor: UIColor {
    return UIColor.darkGray
  }

  var labelColor: UIColor {
    return UIColor.darkGray
  }

}

DTRuler.theme = Colorful()

Latest podspec

{
    "name": "DTRuler",
    "version": "1.0.2",
    "summary": "Simple ruler input control",
    "homepage": "https://github.com/danjiang/DTRuler",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Dan Jiang": "[email protected]"
    },
    "social_media_url": "https://twitter.com/danjianglife",
    "platforms": {
        "ios": "8.4"
    },
    "requires_arc": true,
    "swift_version": "4.0",
    "source": {
        "git": "https://github.com/danjiang/DTRuler.git",
        "tag": "1.0.2",
        "submodules": true
    },
    "source_files": "Sources/**/*.{h,swift}"
}

Pin It on Pinterest

Share This