christoff-1992 / DPSegmentedControl

Segmented control with image and title

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DPSegmentedControl

This is a custom Segmented Control with icon and text on every segment. DPSegmentedControl is tested on iOS 10.0 This awesome library is wrote on swift 3

Usage

Initialization segmented control with icon

let segmentedControl = DPSegmentedControl.init(
            FrameWithIcon: CGRect(x: 8, y: 50, width: view.frame.width - 16, height: 44),
            items: ["Happy", "Normal", "Sad"],
            icons: [UIImage(named: "happy_gray")!, UIImage(named: "flat_gray")!, UIImage(named: "sad_gray")!],
            selectedIcons: [UIImage(named: "happy_white")!, UIImage(named: "flat_white")!, UIImage(named: "sad_white")!],
            backgroundColor: UIColor(red: 230/255, green: 230/255, blue: 230/255, alpha: 1),
            thumbColor: UIColor.init(hex: "#54C3EF"),
            textColor: UIColor(hex: "#808080"),
            selectedTextColor: UIColor(hex: "#FFFFFF"),
            orientation: ComponentOrientation.LeftRight)

Initialization segmented control without icon

let segmentedControl = DPSegmentedControl.init(
            FrameWithoutIcon: CGRect(x: 8, y: 50, width: view.frame.width - 16, height: 44),
            items: ["Happy", "Normal", "Sad"],
            backgroundColor: UIColor(red: 230/255, green: 230/255, blue: 230/255, alpha: 1),
            thumbColor: UIColor.init(hex: "#54C3EF"),
            textColor: UIColor(hex: "#808080"),
            selectedTextColor: UIColor(hex: "#FFFFFF"))
// To get the changed value event, set it manually on your view controller
segmentedControl.addTarget(self, action: #selector(orderTypeChanged), for: .valueChanged)

// You need to add DPSegmnetedControl to container
self.view.addSubview(segmentedControl)

// You could set the selected index. Default is 0
segmentedControl.selectedIndex = 1

Sample

gif

This is the video sample

Installation

Manual installation. Just copy DPSegmentedControl folder to your project. Will be available on cocoapods soon.

License

DPSegmentedControl is released under the MIT license. See LICENSE for details.

About

Segmented control with image and title

License:MIT License


Languages

Language:Swift 100.0%