Skip to content

Meniny/EASegments

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

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")]")
}

About

🚑 A segments control for iOS.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published