EASegments 1.0.1

EASegments 1.0.1

Maintained by Meniny.



Meet EASegments

EASegments

Author EMail MIT
Version Platforms Swift
Build Passing Cocoapods Carthage SPM

🏵 Introduction

EASegments is a segments control for iOS.

Preivew-Tap.gif
Preview-Pan.gif

📋 Requirements

Type Requirement

Platform

iOS

8.0+

macOS

N/A

tvOS

N/A

watchOS

N/A

Linux

N/A

IDE

Xcode

9.3+

Language

Swift

4.1+

📲 Installation

CocoaPods

EASegments is available on CocoaPods.

use_frameworks!
pod 'EASegments'

Manually

Copy all files in the EASegments directory into your project.

🛌 Dependency

N/A

❤️ Contribution

You are welcome to fork and submit pull requests.

🔖 License

EASegments is open-sourced software, licensed under the MIT license.

🔫 Usage

import EASegments

func setup() {
    let flamingo = #colorLiteral(red: 0.92, green: 0.38, blue: 0.25, alpha: 1.00)

    let segments = EASegments(titles: ["Tweets", "Likes"])
    // use frame, or AutoLayout
    segments.frame = CGRect(x: 30.0, y: 40.0, width: 200.0, height: 30.0)

    segments.backgroundColor = flamingo
    segments.selectedBackgroundColor = .white

    segments.titleColor = .white
    segments.selectedTitleColor = flamingo

    segments.titleFont = UIFont(name: "HelveticaNeue-Medium", size: 13.0)

    // do this:
    // segments.addTarget(self, action: #selector(segmentsValueDidChange(:)), for: .valueChanged)
    // or this:
    segments.delegate = self // EASegmentsDelegate?

    someView.addSubview(segments)
}

// addTarget
@objc
func segmentsValueDidChange(_ sender: EASegments) {
    print("valueChanged: \(sender.selectedIndex) [\(sender.selectedTitle ?? "nil")]")
}

// EASegmentsDelegate
func segments(_ segments: EASegments, didSelectAt index: Int) {
    print("didSelectAt: \(segments.selectedIndex) [\(segments.selectedTitle ?? "nil")]")
}