Skip to content

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

License

Notifications You must be signed in to change notification settings

hudinwal/DHSegmentedControl

Repository files navigation

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.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published