An iOS Switch Control implemented in Swift with full Interface

An iOS Switch Control implemented in Swift and SwiftUI with full Interface

Switch Controls is an iOS custom switch control library. It features an appealing design and highly customizable transfer manager that can be integrated into your iOS applications.

If you need to include a visually beautiful and thrilling transfer with multiple stages in your iOS apps, DGRunkeeperSwitch is a solid framework for developing separate transfer controls. It’s a great option for health, fitness, or activity tracking apps that cover the steps track layout.

Runkeeper design iOS switch control (two part segment control) developed in Swift 2.0

Requirements

  • Xcode 7-beta or higher
  • iOS 8.0 or higher (May work on previous versions, just did not test it. Feel free to edit it).
  • ARC
  • Swift 3.0 (old versions are in different releases)

Demo

Open and run the DGRunkeeperSwitchExample project in Xcode to see DGRunkeeperSwitch in action.

Installation

Manual

All you need to do is drop DGRunkeeperSwitch.swift file into your project

CocoaPods

pod "DGRunkeeperSwitch", "~> 1.1.4"

Example usage

Using DGRunkeeperSwitch as a titleView

let runkeeperSwitch = DGRunkeeperSwitch(titles: ["Feed", "Leaderboard"])
runkeeperSwitch.backgroundColor = UIColor(red: 229.0/255.0, green: 163.0/255.0, blue: 48.0/255.0, alpha: 1.0)
runkeeperSwitch.selectedBackgroundColor = .white
runkeeperSwitch.titleColor = .white
runkeeperSwitch.selectedTitleColor = UIColor(red: 255.0/255.0, green: 196.0/255.0, blue: 92.0/255.0, alpha: 1.0)
runkeeperSwitch.titleFont = UIFont(name: "HelveticaNeue-Medium", size: 13.0)
runkeeperSwitch.frame = CGRect(x: 30.0, y: 40.0, width: 200.0, height: 30.0)
runkeeperSwitch.addTarget(self, action: #selector(ViewController.switchValueDidChange(sender:)), for: .valueChanged)
navigationItem.titleView = runkeeperSwitch

Using as a stand alone control

let runkeeperSwitch2 = DGRunkeeperSwitch()
runkeeperSwitch2.titles = ["Daily", "Weekly", "Monthly", "Yearly"]
runkeeperSwitch2.backgroundColor = UIColor(red: 239.0/255.0, green: 95.0/255.0, blue: 49.0/255.0, alpha: 1.0)
runkeeperSwitch2.selectedBackgroundColor = .white
runkeeperSwitch2.titleColor = .white
runkeeperSwitch2.selectedTitleColor = UIColor(red: 239.0/255.0, green: 95.0/255.0, blue: 49.0/255.0, alpha: 1.0)
runkeeperSwitch2.titleFont = UIFont(name: "HelveticaNeue-Medium", size: 13.0)
runkeeperSwitch2.frame = CGRect(x: 50.0, y: 20.0, width: view.bounds.width - 100.0, height: 30.0)
runkeeperSwitch2.autoresizingMask = [.flexibleWidth] // This is needed if you want the control to resize
view.addSubview(runkeeperSwitch2)

Github – An iOS Switch Control in Swift

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *