Latest 2.0.4
Homepage https://github.com/wsj2012/EasySegmentedControl
License MIT
Platforms ios 9.0, requires ARC
Authors

Thanks for the author of HMSegmentedControl(oc version).
This is swift version of HMSegmentedControl.
A drop-in replacement for UISegmentedControl mimicking the style of the segmented control used in Google Currents and various other Google products.

Features

  • Supports both text and images
  • Support horizontal scrolling
  • Supports advanced title styling with text attributes for font, color, kerning, shadow, etc.
  • Supports selection indicator both on top and bottom
  • Supports blocks
  • Works with ARC and iOS >= 9

Installation

CocoaPods

The easiest way of installing EasySegmentedControl is via CocoaPods.

pod 'EasySegmentedControl'

Old-fashioned way

  • Add EasySegmentedControl.swift to your project.
  • Add QuartzCore.framework to your linked frameworks.

Usage

The code below will create a segmented control with the default looks:

        let viewWidth = view.frame.size.width
        let sc = EasySegmentedControl.init(with: ["Trending", "News", "Library"])
        sc.frame = CGRect(x: 0, y: 88, width: viewWidth, height: 40)
        sc.autoresizingMask = [.flexibleRightMargin, .flexibleWidth]
        sc.backgroundsColor = UIColor.clear
        sc.addTarget(self, action: #selector(segmentedControlChangedValue(segmentedControl:)), for: .valueChanged)
        view.addSubview(sc)

Included is a demo project showing how to fully customise the control.

EasySegmentedControl

Apps using EasySegmentedControl

If you are using EasySegmentedControl in your app or know of an app that uses it, please add it to this list.

License

EasySegmentedControl is licensed under the terms of the MIT License. Please see the LICENSE file for full details.

If this code was helpful, I would love to hear from you.

Latest podspec

{
    "name": "EasySegmentedControl",
    "version": "2.0.4",
    "summary": "swiftu7248u672cHMSegmentedControl,u4e00u4e2au597du7528u7684u7b2cu4e09u65b9u5206u6bb5u63a7u5236u5668u5e93uff0cu6837u5f0fu53efu6df1u5ea6u7075u6d3bu5b9au5236u3002",
    "homepage": "https://github.com/wsj2012/EasySegmentedControl",
    "license": "MIT",
    "authors": {
        "wsj_2012": "[email protected]"
    },
    "source": {
        "git": "https://github.com/wsj2012/EasySegmentedControl.git",
        "tag": "2.0.4"
    },
    "requires_arc": true,
    "platforms": {
        "ios": "9.0"
    },
    "source_files": "EasySegmentedControlSource/*.{swift}",
    "swift_version": "4.2"
}

Pin It on Pinterest

Share This