hudinwal / DHSegmentedControl

DHSegmentedControl is drop in replacement of the UISegementedControl. Why you need it? If you have lots of segments, UISegmentedControl breaks the UI.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DHSegmentedControl

Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

DHSegmentedControl is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "DHSegmentedControl"

Usage

        // In appropriate function, maybe viewDidLoad(), we create the segments
        var segments = [DHSemgentTitleContainable]()
        
        segments.append(DHSegmentTitle("ALL"))
        segments.append(DHSegmentTitle("EAT"))
        segments.append(DHSegmentTitle("DRINK"))
        segments.append(DHSegmentTitle("DESSERT"))
        segments.append(DHSegmentTitle("EVENTS"))
        segments.append(DHSegmentTitle("SITES"))

        // With these segments we then create a Segmented Control
        let scrollabelSegmentControl = DHSegmentedControl(items: segments)
        
        //Later on set the frames of the control
        scrollabelSegmentControl.frame = segmentsContainer.bounds;
        scrollabelSegmentControl.autoresizingMask = [.flexibleLeftMargin, .flexibleRightMargin,.flexibleWidth]
        scrollabelSegmentControl.addTarget(self, action: #selector(segmentControlValueChanged(segmentControl:)), for: .valueChanged)
        // In the end add the control to the view
        self.segmentsContainer.addSubview(scrollabelSegmentControl)

Author

d_hudinwal, dinesh_hudinwal@hotmail.com

License

DHSegmentedControl is available under the MIT license. See the LICENSE file for more info.

About

DHSegmentedControl is drop in replacement of the UISegementedControl. Why you need it? If you have lots of segments, UISegmentedControl breaks the UI.

License:MIT License


Languages

Language:Shell 55.8%Language:Swift 34.0%Language:Ruby 5.4%Language:Objective-C 4.8%