Skip to content

Latest commit

 

History

History
39 lines (28 loc) · 1.28 KB

README.md

File metadata and controls

39 lines (28 loc) · 1.28 KB

License Platform Swift

SegmentedControl

A custom animated segmented control

Demo

Installation

Download the SegmentedControl.swift file and add it into your own project

Usage

class ViewController: UIViewController {

  override func viewDidLoad() {
    super.viewDidLoad()

    setupSegmentedControl()
  }
	
  func setupSegmentedControl() {
    let segmentedControl = SegmentedControl(frame: CGRect(x:0, y:0, width: 200, height: 45), tabIcons: [UIImage(named: "beer_icon"), UIImage(named: "bar_icon"), UIImage(named: "night_club"), UIImage(named: "restaurant")], controlColor:   UIColor.orange, selectedTabColor: UIColor.white, tabTintColor: UIColor.white)
    segmentedControl.delegate = self
    view.addSubview(segmentedControl)
  }

}

extension ViewController: SegmentedControlDelegate {
	
	func tabSelected(atIndex index: Int) {
		print("Selected tab at index \(index)")
	}
}