All Projects → Yalantis → Segmentio

Yalantis / Segmentio

Licence: mit
Animated top/bottom segmented control written in Swift.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Segmentio

Colormatchtabs
This is a Review posting app that let user find interesting places near them
Stars: ✭ 1,341 (-41.95%)
Mutual labels:  cocoapods, carthage, yalantis
Ktvhttpcache
A powerful media cache framework.
Stars: ✭ 2,113 (-8.53%)
Mutual labels:  cocoapods, carthage
Pull To Refresh.rentals Ios
This project aims to provide a simple and customizable pull to refresh implementation. Made in Yalantis
Stars: ✭ 2,171 (-6.02%)
Mutual labels:  cocoapods, yalantis
Displayswitcher
Custom transition between two collection view layouts
Stars: ✭ 2,253 (-2.47%)
Mutual labels:  cocoapods, yalantis
Fittrack
Concept of a fitness app.
Stars: ✭ 165 (-92.86%)
Mutual labels:  cocoapods, yalantis
Bluetoothkit
Easily communicate between iOS/OSX devices using BLE
Stars: ✭ 2,027 (-12.25%)
Mutual labels:  cocoapods, carthage
Swiftyanimate
Composable animations in Swift
Stars: ✭ 194 (-91.6%)
Mutual labels:  cocoapods, carthage
Bluetonium
Bluetooth mapping in Swift
Stars: ✭ 159 (-93.12%)
Mutual labels:  cocoapods, carthage
Wkcookiewebview
WKWebView with cookie sharing support
Stars: ✭ 171 (-92.6%)
Mutual labels:  cocoapods, carthage
Irldocumentscanner
A drop-in Objective-C ViewController that will Automatically scan a document for you you.
Stars: ✭ 172 (-92.55%)
Mutual labels:  cocoapods, carthage
Icimulator
Simulate camera functions on iOS Simulator with images, videos, or your MacBook Camera.
Stars: ✭ 177 (-92.34%)
Mutual labels:  cocoapods, carthage
Forecastio
A Swift library for the Forecast.io Dark Sky API
Stars: ✭ 164 (-92.9%)
Mutual labels:  cocoapods, carthage
Pulltomakesoup
Custom animated pull-to-refresh that can be easily added to UIScrollView
Stars: ✭ 1,928 (-16.54%)
Mutual labels:  carthage, yalantis
Multipeer
📱📲 A wrapper for the MultipeerConnectivity framework for automatic offline data transmission between devices
Stars: ✭ 170 (-92.64%)
Mutual labels:  cocoapods, carthage
Kvkcalendar
A most fully customization calendar and timeline library for iOS 📅
Stars: ✭ 160 (-93.07%)
Mutual labels:  cocoapods, carthage
Svprogresshud
A clean and lightweight progress HUD for your iOS and tvOS app.
Stars: ✭ 12,339 (+434.16%)
Mutual labels:  cocoapods, carthage
Imagetransition
Library for smooth animation of images during transitions.
Stars: ✭ 195 (-91.56%)
Mutual labels:  cocoapods, carthage
Cdmarkdownkit
An extensive Swift framework providing simple and customizable markdown parsing.
Stars: ✭ 158 (-93.16%)
Mutual labels:  cocoapods, carthage
Zkudid
Generate and save permanent UDID with IDFV and keychain in iOS device.
Stars: ✭ 159 (-93.12%)
Mutual labels:  cocoapods, carthage
Cocoalumberjack
A fast & simple, yet powerful & flexible logging framework for Mac and iOS
Stars: ✭ 12,584 (+444.76%)
Mutual labels:  cocoapods, carthage

Segmentio

Platform License Swift 5 Carthage compatible Swift Package Manager

Animated top/bottom segmented control written in Swift.

Preview

Check this project on dribbble.

Requirements

  • Xcode 10
  • iOS 8.x+
  • Swift 5.0

Installation

CocoaPods

use_frameworks! 

pod 'Segmentio'

CocoaPods v1.1.0 or later required

Carthage

github "Yalantis/Segmentio"

Usage

Import Segmentio module

import Segmentio

Init

You can initialize a Segmentio instance from code:

var segmentioView: Segmentio!

let segmentioViewRect = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 125)
segmentioView = Segmentio(frame: segmentioViewRect)
view.addSubview(segmentioView)

or

add a UIView instance in your .storyboard or .xib, set Segmentio class and connect IBOutlet:

@IBOutlet weak var segmentioView: Segmentio!

Setup Segmentio

segmentioView.setup(
	content: [SegmentioItem],
	style: SegmentioStyle,
	options: SegmentioOptions?
)

To start with default options you can just pass nil to the options parameter.

segmentioView.setup(
	content: [SegmentioItem],
	style: SegmentioStyle,
	options: nil
)

Configuring items

In order to set items you need to create an array of SegmentioItem instances:

var content = [SegmentioItem]()

let tornadoItem = SegmentioItem(
	title: "Tornado",
	image: UIImage(named: "tornado")
)
content.append(tornadoItem)

Handling selection

You can specify selected item manually:

segmentioView.selectedSegmentioIndex = 0

Handling callback

segmentioView.valueDidChange = { segmentio, segmentIndex in
	print("Selected item: ", segmentIndex)
}

Customization

Segmentio can be customized by passing an instance of SegmentioOptions struct:

SegmentioOptions(
            backgroundColor: .white,
            segmentPosition: SegmentioPosition,
            scrollEnabled: true,
            indicatorOptions: SegmentioIndicatorOptions,
            horizontalSeparatorOptions: SegmentioHorizontalSeparatorOptions,
            verticalSeparatorOptions: SegmentioVerticalSeparatorOptions,
            imageContentMode: .center,
            labelTextAlignment: .center,
            segmentStates: SegmentioStates
)

Segment width rely on SegmentioPosition enum. Width can be fixed according to maximum visible items or dynamic according to segment's content size:

enum SegmentioPosition {
    case dynamic
    case fixed(maxVisibleItems: Int)
}

Selection indicator can be customized by passing an instance of SegmentioIndicatorOptions:

SegmentioIndicatorOptions(
            type: .bottom,
            ratio: 1,
            height: 5,
            color: .orange
)

Horizontal borders can be customized by passing an instance of SegmentioHorizontalSeparatorOptions:

SegmentioHorizontalSeparatorOptions(
            type: SegmentioHorizontalSeparatorType.topAndBottom, // Top, Bottom, TopAndBottom
            height: 1,
            color: .gray
)

Separators between segments can be customized by passing an instance of SegmentioVerticalSeparatorOptions:

SegmentioVerticalSeparatorOptions(
            ratio: 0.6, // from 0.1 to 1
            color: .gray
)

In order to set SegmentioStates you need to create a tuple of SegmentioState instances:

SegmentioStates(
            defaultState: SegmentioState(
                backgroundColor: .clear,
                titleFont: UIFont.systemFont(ofSize: UIFont.smallSystemFontSize),
                titleTextColor: .black
            ),
            selectedState: SegmentioState(
                backgroundColor: .orange,
                titleFont: UIFont.systemFont(ofSize: UIFont.smallSystemFontSize),
                titleTextColor: .white
            ),
            highlightedState: SegmentioState(
                backgroundColor: UIColor.lightGray.withAlphaComponent(0.6),
                titleFont: UIFont.boldSystemFont(ofSize: UIFont.smallSystemFontSize),
                titleTextColor: .black
            )
)

Let us know!

We’d be really happy if you sent us links to your projects where you use our component. Just send an email to [email protected] And do let us know if you have any questions or suggestion regarding the animation.

P.S. We’re going to publish more awesomeness wrapped in code and a tutorial on how to make UI for iOS (Android) better than better. Stay tuned!

License

The MIT License (MIT)

Copyright © 2019 Yalantis

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].