Skip to content

Aiur3908/AYSegmentedControls

Repository files navigation

AYSegmentedControls

Custom SegmentedControls

Swift 4.2 CocoaPods Compatible Carthage compatible Build Status Platform License image

Installation

CocoaPods

pod 'AYSegmentedControls'

Carthage

github "Aiur3908/AYSegmentedControls"

Manually

Add the AYSegmentedControls.swift file to your project.

Usage

Initialization

init(coder:) (storyboard or xib)

  1. Add UIView

image

  1. Set AYSegmentedControls as Custom Class.

image

  1. Connect IBOutlet

image

init(frame: )

let segmentedControls = AYSegmentedControls(frame: CGRect(x: 100,
                                                          y: 100,
                                                          width: 300,
                                                          height: 50))
view.addSubview(segmentedControls)

DataSource & Delegate

segmentedControls.dataSource = self
segmentedControls.delegate = self

DataSource

///The number of item that the segmentedControls should display.
func numberOfItem(in segmentedControls: AYSegmentedControls) -> Int 

///The string to use as the title of the item.
func segmentedControls(_ segmentedControls: AYSegmentedControls,
                       titleForItemAt index: Int) -> String

Delegate

///Called by the segmentedControls when the user selects an item.
func segmentedControls(_ segmentedControls: AYSegmentedControls,
                       didSelectItemAt index: Int)
                       

Custom Properties

///HintView background
var hintColor: UIColor 
///SegmentedControls border width
var borderWidth: CGFloat
///SegmentedControls border color
var bordrColor: CGFloat
///Content padding
var padding: CGFloat 
///Normal status title color
var normalTitleColor: UIColor 
///Selected status title color
var selectedTitleColor: UIColor 
///Title Font
var titleFont: UIFont

SelectedIndex

segmentedControls.selectedIndex = 1

or

segmentedControls.selectIndex(at: 2, animated: true)

Author

Jerry You Email: Aiur3908@gmail.com

LICENSE

MIT

About

Custom SegmentedControls

Resources

License

Stars

Watchers

Forks

Packages

No packages published