A minimalistic looking banner library for iOS. It supports multiple customizable kinds of Banner types

Overview

SYBanner

Commit Platform Swift 5.0 iOS 13.0+ MIT



A minimalistic looking banner library for iOS. It supports multiple customizable kinds of Banner types

Quick start

SYSimpleBanner

let banner = SYSimpleBanner("Link copied", backgroundColor: .white, direction: .top)
banner.animationDurationDisappear = 0.1
banner.show()
SYDefaultBanner:

let textBanner = SYDefaultBanner("A Banner with just a text", direction: .top, style: .none)
textBanner.animationDurationDisappear = 0.1
textBanner.show()

let styleBanner = SYDefaultBanner("A Banner with just a text", direction: .top, style: .success)
styleBanner.show(queuePosition: .front)
SYCardBanner

let banner = SYCardBanner(title: "How to use", subtitle: "Simple download Notification banner and get started with your own notifcations")
banner.addButton(SYCardBannerButton(title: "Skip ", style: .dismiss)
banner.addButton(SYCardBannerButton(title: "Get started", style: .default, handler: {
    // Do something on button press
}))

// See Banner options for more
banner.setBannerOptions([
  .showExitButton(true),
  .customView(yourCustomView()),
  .buttonAxis(.horizontal),
  .titleFont(UIFont.systemFont(ofSize: 35, weight: .medium)),
  .titleColor(.gray),
  .buttonsHeight(50),
  .customViewInsets(.init(top: 20, left: 0, bottom: 40, right: 0)),
])

banner.dismissOnSwipe = false
banner.show()

By default each banner is placed at the at the end of the queue. If your want to display the banner immediately place it at the front of the queue:

banner.show(queuePosition: .front)

By default each banner will be dismissed after a time. If you want to disable that, set autoDismiss to false and dismiss manually:

banner.dismissView()
SYBannerButton Style

Currently there are only 2 Button style options. Defaults is the default iOS Button with the default or the specified tint color.
The dismiss style dismisses the banner when pressed and does not have a tint color.

public enum Style : Int {
  case `default` = 0
  case dismiss = 1
}
Delegate

To respond to animation events, implement the SYBannerDelegate protocol in your class, e.g. a View Controller, and then set the banners delegate property:

class MyViewController: UIViewController, SYBannerDelegate {
  override func viewDidLoad() {
    let banner = SYSimpleBanner("Link copied", direction: .top)
    banner.delegate = self
    banner.show()
  }

  // Banner delegate
  func notificationBannerWillAppear(_ banner: SYBaseBanner) {
    // Do something before the banner appears
  }

  func notificationBannerDidAppear(_ banner: SYBaseBanner) {
    // Do something when the banner appeared
  }
  func notificationBannerWillDisappear(_ banner: SYBaseBanner) {
    // Do something before the banner disappears
  }

  func notificationBannerDidDisappear(_ banner: SYBaseBanner) {
    // Do something after the banner disappeared
  }
}
User interaction

To respond to animation events, implement the SYBannerDelegate protocol in your class, e.g. a View Controller, and then set the banners delegate property:

banner.onSwipe = {
    // Do something on swipe
}
banner.didTap = {
    // Do something on tap
}

Banner options

Banner Options

Option Name Description
direction The direction of the banner (Direction, default .bottom)
isDisplaying Flag indicating if the banner is currently displaying
hasBeenSeen Flag indicated whether if the banner has been seen
bannerType Type of the Banner (SYBannerType, default .float)
parentViewController The view controller to display the banner on. This is useful if you are wanting to display a banner only on one ViewController and not on the whole screen
delegate The delegate of the banner (.SYBannerDelegate)
animationDurationShow Animation duration of the notification for appearing (CGFloat, default 0.5)
animationDurationDisappear Animation duration of the notification for disappearing (CGFloat, default 0.5)
appearanceDuration Duration for whole long the notification should appear on the screen (Timeinterval, default 5)
bannerQueue Responsible for positioning and auto managing notification banners (SYBannerQueue, default .default)
autoDismiss If false, the banner will not be dismissed until it is programmatically dismissed (Bool, default true)
dismissOnTap If true, notification will dismissed when tapped (Bool, default true)
dismissOnSwipe If true, notification will dismissed when swiped up (Bool, default true)
onSwipe Closure that will be executed if the notification banner is swiped up ((() -> Void)?, default nil)
didTap Closure that will be executed if the notification banner is tapped ((() -> Void)?, default nil)
transparency The transparency of the background of the notification banner (CGFloat, default 1 )
haptic The type of haptic to generate when a banner is displayed (FeedbackStyle?, default .medium)

SYSimpleBanner, SYDefaultBanner:

Option Name Description
message The message of the notification
messageColor Color of the message label (UIColor, default .label)
messageFont Font of the message label (UIFont, default .systemFont(ofSize: 16))
messageInsets Insets of the label inside the banner (UIEdgeInsets, default .init(top: 10, left: 30, bottom: 10, right: 30))

SYDefaultBanner:

Option Name Description
imageView The imageView for the banner will either be set based on the style or the custom icon
customIcon Custom icon for the notification. If none is set the icon of the Notification style will be selected
customBackgroundColor Custom icon for the notification. If none is set the icon of the Notification type will be selected
iconSize The size of the icon (CGSize, default .init(width: 30, height: 30))
style The style for the banner

SYCardBanner:

Option Name Description
titleSubtitleSpacing Spacing between title and subtitle (CGFloat, default 16)
keyboardSpacing Spacing between the view and the keyboard, if shown (CGFloat, default 10)
dismissableOrigin The number of drag necessary for the view to be dismissed. Only works if isDismissable is set to true (CGFloat, default 100)
isDraggable If true, the banner can be moved around. (Bool, default true)
addExitButton If set to true, a exit button will be drawn on the top right corner (Bool, default false)
exitButtonSize The size of the top right exit button. Only visible if addExitButton is true (CGSize, default init(width: 9, height: 9))
customView If true, the banner can be moved around. (Bool, default true)
didTapButton Closure that will be executed if a button is tapped (((_ : SYCardBannerButton) -> Void)?, default nil)
didTapExitButton Closure that will be executed if the exit button is tapped ((() -> Void)?, default nil)

Requirements

  • Xcode 11
  • iOS 13 or later
  • Swift 5 or later

Installation

CocoaPods

You can use CocoaPods to install SYBanner by adding it to your Podfile:

pod 'SYBanner'
Installing SYBanner manually
  1. Download SYBanner.zip from the last release and extract its content in your project's folder.
  2. From the Xcode project, choose Add Files to ... from the File menu and add the extracted files.

Contribute

Contributions are highly appreciated! To submit one:

  1. Fork
  2. Commit changes to a branch in your fork
  3. Push your code and make a pull request
You might also like...
A customizable color picker for iOS in Swift
A customizable color picker for iOS in Swift

IGColorPicker is a fantastic color picker ๐ŸŽจ written in Swift. Table of Contents Documentation Colors Style Other features Installation Example Gettin

Modular and customizable Material Design UI components for iOS
Modular and customizable Material Design UI components for iOS

Material Components for iOS Material Components for iOS (MDC-iOS) helps developers execute Material Design. Developed by a core team of engineers and

Simple and highly customizable iOS tag list view, in Swift.
Simple and highly customizable iOS tag list view, in Swift.

TagListView Simple and highly customizable iOS tag list view, in Swift. Supports Storyboard, Auto Layout, and @IBDesignable. Usage The most convenient

Customizable CheckBox / RadioButton component for iOS
Customizable CheckBox / RadioButton component for iOS

GDCheckbox An easy to use CheckBox/Radio button component for iOS, with Attributes inspector support. Requirements Xcode 10+ Swift 5 iOS 9+ Installati

๐Ÿ“Š A customizable gradient progress bar (UIProgressView).
๐Ÿ“Š A customizable gradient progress bar (UIProgressView).

GradientProgressBar A customizable gradient progress bar (UIProgressView). Inspired by iOS 7 Progress Bar from Codepen. Example To run the example pro

Highly customizable Action Sheet Controller with Assets Preview written in Swift
Highly customizable Action Sheet Controller with Assets Preview written in Swift

PPAssetsActionController Play with me โ–ถ๏ธ ๐Ÿ– If you want to play with me, just tap here and enjoy! ๐ŸŽฉ ๐Ÿ•ด Show me ๐ŸŽช Try me ๐Ÿ“ฒ The easiest way to try me

RangeSeedSlider provides a customizable range slider like a UISlider.
RangeSeedSlider provides a customizable range slider like a UISlider.

RangeSeekSlider Overview RangeSeekSlider provides a customizable range slider like a UISlider. This library is based on TomThorpe/TTRangeSlider (Objec

An easy to use UI component to help display a signal bar with an added customizable fill animation
An easy to use UI component to help display a signal bar with an added customizable fill animation

TZSignalStrengthView for iOS Introduction TZSignalStrengthView is an easy to use UI component to help display a signal bar with an added customizable

A customizable Joystick made with SwiftUI
A customizable Joystick made with SwiftUI

SwiftUIJoystick ๐Ÿ•น๏ธ A customizable Joystick made with SwiftUI Create your own Base and Thumb/Handle view using SwiftUI Examples ๐Ÿ“ฒ Installation Swift

Comments
  • Added Swift Package Manager support + Objective-C compatibility

    Added Swift Package Manager support + Objective-C compatibility

    Hi,

    I've added a simple Package.swift to allow this package to be imported in Xcode via the standard Swift Package Manager, as CocoaPods is becoming increasingly deprecated.

    Also made a couple of small changes to make the queue more usable from Objective-C.

    opened by megastep 1
  • Stacking of multiple banners

    Stacking of multiple banners

    Currently there is only the option to present a banner immediately or add it to the queue. Incrementing maxBannersOnScreenSimultaneously should stack the banners on the screen by animating the currently presented banner to a new frame

    enhancement Hacktoberfest 
    opened by emrearmagan 0
Owner
Emre Armagan
Golang, Swift, Java, Python - Full-time computer-science student at the University of Hamburg.
Emre Armagan
๐Ÿ’ˆ Retro looking progress bar straight from the 90s

Description Do you miss the 90s? We know you do. Dial-up internet, flickering screens, brightly colored websites and, of course, this annoyingly slow

HyperRedink 18 Nov 24, 2022
Base types for theming an app.

CostumeKit ?? Base types for theming an app. CostumeKit is made of up a set of Swift protocols. They are meant to be implemented by you in your app. F

Jake Marsh 301 Nov 21, 2022
SheetPresentation for SwiftUI. Multiple devices support: iOS, watchOS, tvOS, macOS, macCatalyst.

SheetPresentation for SwiftUI. Multiple devices support: iOS, watchOS, tvOS, macOS, macCatalyst.

Aben 13 Nov 17, 2021
Pull up controller with multiple sticky points like in iOS Maps

PullUpController Create your own pull up controller with multiple sticky points like in iOS Maps Features Multiple sticky points Landscape support Scr

Mario Iannotta 1.2k Dec 22, 2022
ScrollView that supports a parallax header image and static overlay.

ScrollViewReactiveHeader A replacement ScrollView that provides a header with subtle scroll animations. example-video.mov Using ScrollViewReactiveHead

null 49 Dec 29, 2022
UISlider clone with multiple thumbs and values, range highlight, optional snap intervals, optional value labels, either vertical or horizontal.

MultiSlider UISlider clone with multiple thumbs and values, range highlight, optional snap intervals, optional value labels, either vertical or horizo

Yonat Sharon 326 Dec 29, 2022
A SwiftUI Views for wrapping HStack elements into multiple lines

SwiftUI WrappingStack A SwiftUI Views for wrapping HStack elements into multiple lines. List of supported views WrappingHStack - provides HStack that

Denis 50 Jan 6, 2023
A custom UIControl which functions like UISlider where you can set multiple intervals with different step values for each interval.

MultiStepSlider A custom UIControl which functions like UISlider where you can set multiple intervals with different step values for each interval. Th

Susmita Horrow 25 Apr 28, 2022
Customizable School Timetable Library

JHTimeTable SwiftUI Customizable School TimeTable Library ์„ค์น˜ Swift Package Manager ์‚ฌ์šฉํ•˜๊ธฐ JHTimeTable๋ทฐ๋ฅผ ์„ ์–ธํ•ฉ๋‹ˆ๋‹ค. JHTimeTable(lineColor : .secondary,

LeeProgrammer 4 Jan 6, 2023
A simple, customizable view for efficiently collecting country information in iOS apps.

CountryPickerView CountryPickerView is a simple, customizable view for selecting countries in iOS apps. You can clone/download the repository and run

Kizito Nwose 459 Dec 27, 2022