A message bar for iOS written in Swift.

Overview

Dodo, a message bar for iOS / Swift

Carthage compatible CocoaPods Version Swift Package Manager compatible License Platform

Dodo, a message bar for iOS

This is a UI widget for showing text messages in iOS apps. It is useful for showing short messages to the user, something like: "Message sent", "Note saved", "No Internet connection".

  • Dodo includes styles for success, info, warning and error type messages.
  • The bar can have buttons with custom tap handlers.
  • Bar styles can be customized.
  • You can provide custom animations for showing and hiding the bar or use one of the default animation presets.
  • Supports iOS 9+.

Illustration fromAlice's Adventures in Wonderland by John Tenniel

At last the Dodo said, `EVERYBODY has won, and all must have prizes.'

From Alice's Adventures in Wonderland. Original illustration by John Tenniel, 1865. Source: Wikimedia Commons.

Setup

There are multiple ways you can add Dodo to your project.

Add source

Simply add DodoDistrib.swift file into your Xcode project.

Setup with Carthage

Add github "evgenyneu/Dodo" ~> 13.0 to your Cartfile and run carthage update.

Setup with CocoaPods

If you are using CocoaPods add this text to your Podfile and run pod install.

use_frameworks!
target 'Your target name'
pod 'Dodo', '~> 13.0'

Setup with Swift Package Manager

Legacy Swift versions

Setup a previous version of the library if you use an older version of Swift.

Usage

Add import Dodo to your source code (unless you used the file setup method).

Dodo is an extension of UIView class. You can reach it by using using the dodo property in any instance of UIView or its subclass. It can be, for example, the view property of your view controller.

Show and hide message bar

view.dodo.success("Everybody has won and all must have prizes.")
view.dodo.info("Extinction is the rule. Survival is the exception.")
view.dodo.warning("This world is but a canvas to our imagination.")
view.dodo.error("The perception of beauty is a moral test.")

view.dodo.hide()

If you are showing the bar in the root view you may need to provide top or bottom anchors. This will prevent the message bar from overlapping with the status or the tab bar.

view.dodo.topAnchor = view.safeAreaLayoutGuide.topAnchor
view.dodo.bottomAnchor = view.safeAreaLayoutGuide.bottomAnchor
view.dodo.success("I solemnly swear to avoid the notch.")

Alternatively, you can specify the anchors from the layout guides:

view.dodo.topAnchor = topLayoutGuide.bottomAnchor
view.dodo.bottomAnchor = bottomLayoutGuide.topAnchor
view.dodo.success("I solemnly swear to avoid the notch.")

Dodo success presets

Dodo info presets

Dodo warning presets

Dodo error presets

Styling

Set dodo.style property to style the message bar before it is shown. See the styling manual for the complete list of configuration options.

// Set the text color
view.dodo.style.label.color = UIColor.white

// Set background color
view.dodo.style.bar.backgroundColor = DodoColor.fromHexString("#00000090")

// Close the bar after 3 seconds
view.dodo.style.bar.hideAfterDelaySeconds = 3

// Close the bar when it is tapped
view.dodo.style.bar.hideOnTap = true

// Show the bar at the bottom of the screen
view.dodo.style.bar.locationTop = false

// Do something on tap
view.dodo.style.bar.onTap = { /* Tapped on the bar */ }

Add buttons or icons

Set style.leftButton and style.rightButton properties to show buttons or icons. As with other style properties please style the buttons before the message is shown.

// Use a built-in icon
view.dodo.style.leftButton.icon = .close

// Supply your image
view.dodo.style.leftButton.image = UIImage(named: "CloseIcon")

// Change button's image color
view.dodo.style.leftButton.tintColor = DodoColor.fromHexString("#FFFFFF90")

// Do something on tap
view.dodo.style.leftButton.onTap = { /* Button tapped */ }

// Close the bar when the button is tapped
view.dodo.style.leftButton.hideOnTap = true

Dodo bar with left buttons

Dodo bar with right and left buttons

Customize animation

Configure the animation effect of the bar before it is shown. See the animation wiki page for more information.

// Use existing animations
view.dodo.style.bar.animationShow = DodoAnimations.rotate.show
view.dodo.style.bar.animationHide = DodoAnimations.slideRight.hide

// Turn off animation
view.dodo.style.bar.animationShow = DodoAnimations.noAnimation.show

Unit testing

Sometimes it is useful to verify which messages were shown by your app in unit tests. It can be done by setting an instance of DodoMock class to view.dodo property.

See the unit testing manual for more details.

Known limitations

Using Dodo from Objective-C

This manual describes how to show Dodo messages in Objective-C apps.

Demo iOS app

This project includes a demo app.

Dodo message bar demo iOS app

Thanks 👍

Quotes credits

Albert Einstein

Information is not knowledge.

Carl Sagan

Extinction is the rule. Survival is the exception.

George S. Patton

Success is how high you bounce when you hit bottom.

Henry David Thoreau

This world is but a canvas to our imagination.

The perception of beauty is a moral test.

Joe Namath

When you win, nothing hurts.

Lewis Carroll

Everybody has won and all must have prizes.

Malcolm Forbes

Failure is success if we learn from it.

William Blake

If the doors of perception were cleansed everything would appear to man as it is, Infinite.

Alternative solutions

Here are some other message bar libraries for iOS:

License

Dodo is released under the MIT License.

•ᴥ•

This project is dedicated to the dodo, species of flightless birds that lived on the island of Mauritius and became extinct in the 17th century.

You might also like...
A simple custom popup dialog view for iOS written in Swift. Replaces UIAlertController alert style.
A simple custom popup dialog view for iOS written in Swift. Replaces UIAlertController alert style.

A simple custom popup dialog view for iOS written in Swift. Replaces UIAlertController alert style.

FCAlertView is a Flat Customizable AlertView for iOS (Written in Objective C)
FCAlertView is a Flat Customizable AlertView for iOS (Written in Objective C)

FCAlertView FCAlertView is a Flat Customizable AlertView, written in Objective C Quick Links 1. Swift 2. Installation 3. Example App 4. Adding FCAlert

Highly customizable alertview and alert/notification/success/error/alarm popup written in Swift
Highly customizable alertview and alert/notification/success/error/alarm popup written in Swift

CDAlertView is highly customizable alert popup written in Swift. Usage is similar to UIAlertController. Screenshots Animations Usage Basic usage witho

Beautiful animated Alert View. Written in Swift
Beautiful animated Alert View. Written in Swift

SCLAlertView Animated Alert View written in Swift, which can be used as a UIAlertView or UIAlertController replacement. Since UIAlertView is deprecate

Fully customizable and extensible action sheet controller written in Swift
Fully customizable and extensible action sheet controller written in Swift

XLActionController By XMARTLABS. XLActionController is an extensible library to quickly create any custom action sheet controller. Examples The action

 GUI library for displaying various popups (HUD), written in pure Swift.
GUI library for displaying various popups (HUD), written in pure Swift.

SwiftNotice SwiftNotice is a GUI library for displaying various popups (HUD) written in pure Swift, fits any scrollview and supports iPhone X. Feature

Simple Alert View written in Swift, which can be used as a UIAlertController. (AlertController/AlertView/ActionSheet)
Simple Alert View written in Swift, which can be used as a UIAlertController. (AlertController/AlertView/ActionSheet)

DOAlertController Simple Alert View written in Swift, which can be used as a UIAlertController replacement. It supports from iOS7! It is simple and ea

😍A simple NoticeBar written by Swift 3, similar with QQ notice view.
😍A simple NoticeBar written by Swift 3, similar with QQ notice view.

NoticeBar 😍 A simple NoticeBar written by Swift 3, similar with QQ notice view. 😀 ScreenShots Remember: If you want the status bar style change, you

Toasts and popups library written with SwiftUI
Toasts and popups library written with SwiftUI

Popup View Toasts and popups library written with SwiftUI We are a development agency building phenomenal apps. Usage Put all your body code into a ZS

Comments
  • topLayoutGuide issue

    topLayoutGuide issue

    When using the recommended: view.dodo.topLayoutGuide = topLayoutGuide

    The following warning is thrown: 'topLayoutGuide' was deprecated in iOS 11.0

    What's the best-practice way to resolve this? Previously, with specifying the layout guide, the Dodo banner would fall behind the status bars.

    opened by matphillips 15
  • How can I show it a little above the keyboard?

    How can I show it a little above the keyboard?

    AltText

    It's currently showing below the navigation bar and its blocking the keyboard cursor. I'd like to show it a little above the keyboard.

    Here's where I want Dodo to appear.

    AltText

    I tried the following:

    view.dodo.style.bar.locationTop = false
    view.dodo.bottomAnchor = titleTextView.bottomAnchor
    

    Dodo just doesn't appear when I use the above code. What can I do to accomplish this?

    Thanks!

    • Library setup method: CocoaPods
    • Version of the library: 11.0.2
    • Xcode version: 9.2
    • OS version: iOS 11
    opened by tnylee 3
  • possible to use top of all view

    possible to use top of all view

    I've used dodo in scene where inside tab bar controller, if dodo is triggered background another view, I would like to dodo message is should be visible on top wherever user on tab item.

    opened by muhasturk 3
Releases(2.0.2)
Owner
Evgenii Neumerzhitckii
🐋🦔🐢🐝wow
Evgenii Neumerzhitckii
Lightweight dropdown message bar in Swift. It's simple and beautiful.

SwiftyDrop SwiftyDrop is a lightweight pure Swift simple and beautiful dropdown message. Features Easy to use like: Drop.down("Message") Message field

Morita Naoki 691 Nov 20, 2022
zekunyan 608 Dec 30, 2022
A crisp in-app notification/message banner built in Swift.

RMessage Screenshots Intro Welcome to RMessage! RMessage is a simple notification library written in Swift to help you display notification on the scr

Adonis Peralta 407 Nov 29, 2022
Native alert from Apple Music & Feedback. Contains Done, Heart & Message and other presets.

SPAlert Popup from Apple Music & Feedback in AppStore. Contains Done, Heart, Error and other presets. Supports Dark Mode. I tried to recreate Apple's

Ivan Vorobei 1.8k Jan 7, 2023
Native alert from Apple Music & Feedback. Contains Done, Heart & Message and other presets. Support SwiftUI.

SPAlert Popup from Apple Music & Feedback in AppStore. Contains Done, Heart, Error and other presets. Supports Dark Mode. I tried to recreate Apple's

Ivan Vorobei 1.4k Dec 10, 2021
BPStatusBarAlert is a library that allows you to easily make text-based alert that appear on the status bar and below navigation bar.

BPStatusBarAlert BPStatusBarAlert is a library that allows you to easily make text-based alert that appear on the status bar and below navigation bar.

Ben.Park 131 Aug 12, 2022
A simple, customizable popup dialog for iOS written in Swift. Replaces UIAlertController alert style.

Introduction Popup Dialog is a simple, customizable popup dialog written in Swift. Features Easy to use API with hardly any boilerplate code Convenien

Orderella Ltd. 3.8k Dec 20, 2022
Live animated Alert View for iOS written in Swift

Sweet Alert iOS Beautiful Animated custom Alert View inspired from javascript library SweetAlert. Written in Swift this SweetAlertView can be used in

Sahil 2k Dec 22, 2022
A Google like action sheet for iOS written in Swift.

MaterialActionSheetController Lightweight and totally customizable. Create and present it the way you do with UIAlertController. Screenshots Demo | De

Thanh-Nhon NGUYEN 103 Jun 29, 2022
Advance animated alerts for iOS written in Swift

LIHAlert LIHAlert provides animated banners for iOS. Updated to Swift 3 Demo Project The LIHAlert workspace contains a demo project, also used for dev

null 37 Dec 9, 2022