Skip to content
This repository has been archived by the owner on May 6, 2019. It is now read-only.

BrunoMiguens/BMSegmentedControl

 
 

Repository files navigation

BMSegmentedControl

Swift 3.0 license Build Status

This is a custom Segmented Control with icon and text on every segment.

gif

Usage

Initialization segmented control with icon

let segmentedControl = BMSegmentedControl(withIcon: view.bounds,
      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: .white,
      thumbColor: .lightGray,
      textColor: .black,
      selectedTextColor: .cyan,
      orientation: .leftRight
)

Initialization segmented control without icon

let segmentedControl = BMSegmentedControl(withoutIcon: view.bounds,
      items: titles,
      backgroundColor: .white,
      thumbColor: .lightGray,
      textColor: .black,
      selectedTextColor: .cyan
      )
// To get the changed value event, set it manually on your view controller
segmentedControl.addTarget(self, action: #selector(segmentedHasChanged), for: .valueChanged)

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

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

Requirements

  • iOS 8.0+
  • Xcode 8

Integration

CocoaPods (iOS 8+)

You can use CocoaPods to install BMSegmentedControlby adding it to your Podfile:

platform :ios, '8.0'
use_frameworks!

target 'MyApp' do
      pod 'BMSegmentedControl', '~> 0.4.3'
end

License

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

About

Segmented control with image and title

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 95.4%
  • Ruby 4.6%