{"id":2452,"url":"https://github.com/Daltron/NotificationBanner","last_synced_at":"2025-08-06T16:31:15.477Z","repository":{"id":38206491,"uuid":"86640546","full_name":"Daltron/NotificationBanner","owner":"Daltron","description":"The easiest way to display highly customizable in app notification banners in iOS","archived":false,"fork":false,"pushed_at":"2024-07-29T11:24:25.000Z","size":25593,"stargazers_count":4784,"open_issues_count":32,"forks_count":662,"subscribers_count":47,"default_branch":"master","last_synced_at":"2024-10-29T10:57:14.855Z","etag":null,"topics":["ios","ios-animation","ios-swift","swift","swift3"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Daltron.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["daltron"]}},"created_at":"2017-03-30T00:08:49.000Z","updated_at":"2024-10-28T09:07:03.000Z","dependencies_parsed_at":"2023-02-09T20:30:57.345Z","dependency_job_id":"53a28fd4-d34a-4712-b975-0e087be78442","html_url":"https://github.com/Daltron/NotificationBanner","commit_stats":{"total_commits":252,"total_committers":77,"mean_commits":3.272727272727273,"dds":0.5277777777777778,"last_synced_commit":"9550d28f111652614e3957e754cde0d7b349bc43"},"previous_names":[],"tags_count":50,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Daltron%2FNotificationBanner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Daltron%2FNotificationBanner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Daltron%2FNotificationBanner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Daltron%2FNotificationBanner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Daltron","download_url":"https://codeload.github.com/Daltron/NotificationBanner/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228923685,"owners_count":17992566,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ios","ios-animation","ios-swift","swift","swift3"],"created_at":"2024-01-05T20:16:14.112Z","updated_at":"2024-12-09T16:31:00.569Z","avatar_url":"https://github.com/Daltron.png","language":"Swift","funding_links":["https://github.com/sponsors/daltron","https://www.paypal.com/donate/?hosted_button_id=QEBVNMTVX6N88"],"categories":["UI","Libs","Swift","Popups, Banners, Alerts","Uncategorized","2、技术示范","UI [🔝](#readme)","Content","Libraries"],"sub_categories":["Alert \u0026 Action Sheet","UI","Uncategorized","Other free courses","2.2 开发必备的非官方控件","Alert"],"readme":"![Notification Banner](NotificationBanner/Assets/header.png)\n\n[![GitHub contributors](https://img.shields.io/github/contributors/daltron/notificationbanner.svg?style=flat)]() \n[![License](https://img.shields.io/cocoapods/l/NotificationBannerSwift.svg?style=flat)](http://cocoapods.org/pods/NotificationBannerSwift)\n[![PayPal](https://img.shields.io/badge/paypal-donate-yellow.svg)](https://www.paypal.com/donate/?hosted_button_id=QEBVNMTVX6N88)  \n\n## Written in Swift 5\n\nNotificationBanner is an extremely customizable and lightweight library that makes the task of displaying in app notification banners and drop down alerts an absolute breeze in iOS.\n\n| Basic Banners | Banners with Side Views  | Status Bar Banners |\n| ------------- | ------------- | ------------- |\n| ![Basic Banners](NotificationBanner/Assets/basic.gif)  | ![Banners with Side Views](NotificationBanner/Assets/side_views.gif)  | ![Status Bar Banners](NotificationBanner/Assets/status_bar.gif) |\n\n| Growing Banners | Floating Banners  | Stacked Banners |\n| ------------- | ------------- | ------------- | \n| ![Growing Banners](NotificationBanner/Assets/growing.gif)  | ![Floating Banners](NotificationBanner/Assets/floating.gif) | ![Floating Banners](NotificationBanner/Assets/stacked.gif) |\n\n## Features\n- Highly customizable ✅\n- `NSAttributedString` support ✅\n- iPhone, iPhoneX, \u0026 iPad Support ✅\n- Orientation change support ✅\n- Custom `UIView` support ✅\n- Custom colors support ✅\n- Support for long titles/ subtitles ✅\n  - `NotificationBanner` uses horizontal scrolling labels\n  - `GrowingNotificationBanner` grows in height as needed\n- Presenting from top or bottom support ✅\n- Haptic feeback support ✅\n- Built in banner queue ✅\n- Allow to display several banners simultaneously, configurable in banners queue ✅\n- Accessibility support ✅\n- Dynamic Island Support ✅\n\n## Requirements\n\n - iOS 12.0+\n - Xcode 10.0+\n\n## Installation\n\n### Swift Package Manager\n\nThis is the preferred way. All other installation methods are officially deprecated and will no longer be supported in future versions.\n\n1. Go to File \u003e Add Packages\n2. The Add Package dialog appears, by default with Apple packages. \n3. In the upper right hand corner, paste https://github.com/Daltron/NotificationBanner into the search bar\n4. Hit Return to kick off the search\n5. Click Add Package. \n\n### CocoaPods\n\nNotificationBanner is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n#### Swift 5 + Xcode 11 + iOS 13 Support\n\n```ruby\npod 'NotificationBannerSwift', '~\u003e 3.0.0'\n```\n\n#### Swift 5 + Xcode 10.x\n\n```ruby\npod 'NotificationBannerSwift', '2.5.0'\n```\n\n#### Swift 4.2\n\n```ruby\npod 'NotificationBannerSwift', '2.0.1'\n```\n\n#### Swift 4.0\n\n```ruby\npod 'NotificationBannerSwift', '1.6.3'\npod 'MarqueeLabel/Swift', '3.1.6'\n```\n\nThen add `import NotificationBannerSwift` at the top of each file you use NotificationBanner in your project.\n\n### Carthage\n\nTo use NotificationBanner via Carthage simply add this line to your `Cartfile`:\n\n#### Swift 5\n```swift\ngithub \"Daltron/NotificationBanner\" \"master\"\n```\n\nThen add `NotificationBanner.framework` and the dependencies `SnapKit.framework` and `MarqueeLabel.framework` in your project.\n\n## Usage\n\nCreating drop down alerts with NotificationBanner is easy. To create a regular banner (with scrolling labels) and show it, simply:\n\n```swift\nlet banner = NotificationBanner(title: title, subtitle: subtitle, style: .success)\nbanner.show()\n```\n\nIf you want to create a banner which grows in height as needed and show it accordingly just use `GrowingNotificationBanner` instead of `NotificationBanner`:\n\n```swift\nlet banner = GrowingNotificationBanner(title: title, subtitle: subtitle, style: .success)\nbanner.show()\n```\n\nTo create a status bar alert, simply:\n\n```swift\nlet banner = StatusBarNotificationBanner(title: title, style: .success)\nbanner.show()\n```\n\nBy default, each banner will be displayed on the main application window. If you are wanting to show a banner below a navigation bar, simply show on the view controller that is within the navigation system:\n\n```swift\nbanner.show(on: viewController)\n```\n\nBy default, each banner will present from the top. If you are wanting to display from the bottom, simply:\n\n```swift\nbanner.show(bannerPosition: .bottom)\n```\n\nEach of the show properties defined above can be mixed and matched to work flawlessly with eachother.\n\nBy default, each banner will automatically dismiss after 5 seconds. To dismiss programatically, simply:\n\n```swift\nbanner.dismiss()\n```\n\nTo show a banner infinitely until it is manually dismissed, simply:\n\n```swift\nbanner.autoDismiss = false\n```\n\nNotificationBanner has five prebuilt styles that you can choose from:\n\n```swift\npublic enum BannerStyle {\n    case danger\n    case info\n    case customView\n    case success\n    case warning\n}\n```\n\nYou can override the predefined colors that NotificationBanner uses for any style by conforming to the `BannerColorsProtocol`:\n\n```swift\npublic protocol BannerColorsProtocol {\n    func color(for style: BannerStyle) -\u003e UIColor\n}\n```\n\nIts as easy as creating a custom banner colors class:\n\n```swift\nclass CustomBannerColors: BannerColorsProtocol {\n\n    internal func color(for style: BannerStyle) -\u003e UIColor {\n        switch style {\n            case .danger:\t// Your custom .danger color\n            case .info:\t\t// Your custom .info color\n            case .customView:\t// Your custom .customView color\n            case .success:\t// Your custom .success color\n            case .warning:\t// Your custom .warning color\n        }\n    }\n\n}\n```\n\nAnd then passing in that class to any notification banner you create:\n\n```swift\nlet banner = NotificationBanner(title: title, style: .success, colors: CustomBannerColors())\nbanner.show()\n```\n\nBy default, the `.info` style will be applied to the banner if no style is provided in the init method. You can set the background color of a banner at any time by simply setting the `backgroundColor`.\n\n\n### Banners with Side Views\n\nA notification banner can have a left accessory view, a right accessory view, or both:\n\n```swift\n// Success Style Notification with Left View\nlet leftView = UIImageView(image: #imageLiteral(resourceName: \"success\"))\nlet banner = NotificationBanner(title: title, subtitle: subtitle, leftView: leftView, style: .success)\nbanner.show()\n\n // Danger Style Notification with Right View\nlet rightView = UIImageView(image: #imageLiteral(resourceName: \"danger\"))\nlet banner = NotificationBanner(title: title, subtitle: subtitle, rightView: rightView, style: .danger)\nbanner.show()    \n\n// Info Style Notification with Left and Right Views\nlet leftView = UIImageView(image: #imageLiteral(resourceName: \"info\"))\nlet rightView = UIImageView(image: #imageLiteral(resourceName: \"right_chevron\"))\nlet banner = NotificationBanner(title: title, subtitle: subtitle, leftView: leftView, rightView: rightView, style: .info)\nbanner.show()\n```\n![Banners with Side Views](NotificationBanner/Assets/side_views.gif)\n\nEach side view will be automically reisized to fit perfectly\n\n### Banners with a Custom View\n\nA notification banner can also be initalized with a custom view:\n\n```swift\nlet banner = NotificationBanner(customView: NorthCarolinaBannerView())\nbanner.show()\n```\n![Custom Banner](NotificationBanner/Assets/custom.gif)\n\n### Handling User Interaction\n\nBy default, when a banner is tapped or swiped up by a user, it will be dismissed. If you want to detect when the user taps or swipes up on a banner, simply:\n\n```swift\nbanner.onTap = {\n\t// Do something regarding the banner\n}\n```\n\n```swift\nbanner.onSwipeUp = {\n\t// Do something regarding the banner\n}\n```\n\n### Banner Events\n\nYou can choose to opt into a notification banner's events by registering as its delegate:\n\n```swift\nbanner.delegate = self\n```\nThen just make sure to implement the following methods:\n\n```swift\nfunc notificationBannerWillAppear(_ banner: BaseNotificationBanner)\nfunc notificationBannerDidAppear(_ banner: BaseNotificationBanner)\nfunc notificationBannerWillDisappear(_ banner: BaseNotificationBanner)\nfunc notificationBannerDidDisappear(_ banner: BaseNotificationBanner)\n```\n\n## Haptic Feedback Support\nBy default, when a banner is displayed, a haptic feedback will be generated on devices that support it. The types of haptic feedback are as follows:\n\n```swift\npublic enum BannerHaptic {\n\tcase light\n   \tcase medium\n\tcase heavy\n  \tcase none\n}\n```\n\nTo change the type of haptic feedback to generate when a banner is shown, simply:\n\n```swift\nbanner.haptic = .heavy\n```\n\n## Banner Queue\n\nBy default, each notification banner is placed onto a singleton of an auto-managed `NotificationBannerQueue`. This allows an infinite amount of banners to be displayed without one hiding the other. If you have multiple controllers within your navigation stack that need to be managed by a seperate queue (like a tab bar controller), simply create an instance of a `NotificationBannerQueue` and pass it in to the show function:\n\n```swift\nbanner.show(queue: customQueue)\n```\n\nBy default, each notification banner is placed on the back of the queue. If you would rather place the banner in the front and show it immediately no matter how many banners are in the queue, simply state it in the `show()` method:\n\n```swift\nbanner.show(queuePosition: .front)\n```\n\nAdding a banner to the front of the queue will temporarily suspend the currently displayed banner (if there is one) and will resume it after the banner in front of it dismisses.\n\nTo get the number of banners currently on the queue, simply:\n\n```swift\nlet numberOfBanners = NotificationBannerQueue.default.numberOfBanners\n```\n\n \u003cb\u003eThis is all automatically managed!\u003c/b\u003e\n\n## Banner Queue and display banners simultaneously (stacked)\n\nYou can also create the queue to display several banners at once with controlling of maximum number of banners to be displayed simultaneously. You can \"show\" more banners than allowed by queue settings - banners what exceed this value will be displayed some time later, after some banners already displayed on screen will be closed. In example below we create queue with maximum simultaneous banners allowed - 3:\n\n```swift\nlet bannerQueueToDisplaySeveralBanners = NotificationBannerQueue(maxBannersOnScreenSimultaneously: 3)\n```\n\nCreate five different banners:\n\n```swift\nlet banner1 = FloatingNotificationBanner(\n\ttitle: \"Success Notification - 1\",\n\tsubtitle: \"First Notification from 5 in current queue with 3 banners allowed simultaneously\",\n\tstyle: .success\n)\nbanner1.delegate = self\n\nlet banner2 = FloatingNotificationBanner(\n\ttitle: \"Danger Notification - 2\",\n\tsubtitle: \"Second Notification from 5 in current queue with 3 banners allowed simultaneously\",\n\tstyle: .danger\n)\nbanner2.delegate = self\n\nlet banner3 = FloatingNotificationBanner(\n\ttitle: \"Info Notification - 3\",\n\tsubtitle: \"Third Notification from 5 in current queue with 3 banners allowed simultaneously\",\n\tstyle: .info\n)\nbanner3.delegate = self\n\nlet banner4 = FloatingNotificationBanner(\n\ttitle: \"Success Notification - 4\",\n\tsubtitle: \"Fourth Notification from 5 in current queue with 3 banners allowed simultaneously\",\n\tstyle: .success\n)\nbanner4.delegate = self\n\nlet banner5 = FloatingNotificationBanner(\n\ttitle: \"Info Notification - 5\",\n\tsubtitle: \"Fifth Notification from 5 in current queue with 3 banners allowed simultaneously\",\n\tstyle: .info\n)\nbanner5.delegate = self\n```\n\nand show all five banners at once:\n```swift\nshowBanners(\n\t[banner1, banner2, banner3, banner4, banner5],\n\tin: bannerQueue5AllowedMixed\n)\n```\n\nusing this supporting method\n\n```swift\nfunc showBanners(\n\t_ banners: [FloatingNotificationBanner],\n\tin notificationBannerQueue: NotificationBannerQueue\n) {\n    banners.forEach { banner in\n      \tbanner.show(\n\t      \tbannerPosition: selectedBannerPosition(),\n\t\t \tqueue: notificationBannerQueue,\n\t\t \tcornerRadius: 8,\n\t\t\tshadowColor: UIColor(red: 0.431, green: 0.459, blue: 0.494, alpha: 1),\n\t\t  \tshadowBlurRadius: 16,\n\t\t\tshadowEdgeInsets: UIEdgeInsets(top: 8, left: 8, bottom: 0, right: 8)\n\t   )\n    }\n}\n```\n\nIt will display first three banners at once, and after some time (or by user tap) it will be hidden and 4 and 5 banner will be displayed when. All it with fancy animation.\n\n## Feature Requests\n\nI'd love to know anything that you think NotificationBanner is missing. Open an issue and I'll add the `feature request` label to it and I'll do everything I can to accomodate that request if it is in the library's best interest. 😄 \n\n## Apps that Use NotificationBanner\n[![Q - Talk About Music](AppIcons/q_talk_about_music.jpg)](https://itunes.apple.com/us/app/q-talk-about-music/id1071551321?mt=8) \n[![VH Dispatch](AppIcons/vh_dispatch.png)](https://apps.apple.com/app/vh-dispatch/id1249569084)\n[![Stikkr](AppIcons/stikkr.png)](https://apps.apple.com/app/stikkr/id851375015)\n[![CardCast](AppIcons/cardcast.png)](https://apps.apple.com/app/cardcast-business-cards/id1269278947)\n[![Happy Scale](AppIcons/happy_scale.png)](https://apps.apple.com/app/happy-scale/id532430574)\n[![Wanderings](AppIcons/wanderings.png)](https://apps.apple.com/app/wanderings-travel-tracking/id1292503352)\n[![Modern Magic 8 Ball](AppIcons/modernmagic8ball.png)](https://apps.apple.com/app/modern-magic-8-ball/id1381145384)\n[![Envision: Habits Tracker](AppIcons/envision.png)](https://apps.apple.com/app/envision-habits-tracker/id1423771095)\n[![TSUM](AppIcons/tsum.png)](https://apps.apple.com/ru/app/%D1%86%D1%83%D0%BC-%D0%B8%D0%BD%D1%82%D0%B5%D1%80%D0%BD%D0%B5%D1%82-%D0%BC%D0%B0%D0%B3%D0%B0%D0%B7%D0%B8%D0%BD-%D0%BE%D0%B4%D0%B5%D0%B6%D0%B4%D1%8B/id1089560311)\n[![RIS](AppIcons/ris.png)](https://apps.apple.com/ru/app/%D1%80%D0%B5%D1%81%D1%82%D0%BE%D1%80%D0%B0%D0%BD%D1%8B-%D1%80%D0%B8%D1%81-%D0%B7%D0%B0%D0%BA%D0%B0%D0%B7-%D0%B4%D0%BE%D1%81%D1%82%D0%B0%D0%B2%D0%BA%D0%B0/id932844115)\n[![LukaPizza](AppIcons/lukapizza.png)](https://apps.apple.com/ru/app/luka-pizza-%D0%B7%D0%B0%D0%BA%D0%B0%D0%B7-%D0%B8-%D0%B4%D0%BE%D1%81%D1%82%D0%B0%D0%B2%D0%BA%D0%B0/id1202155629)\n\n#### Feel free to add yours!\n\n## Author\n\nDalton Hinterscher, daltonhint4@gmail.com\n\n## License\n\nNotificationBanner is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDaltron%2FNotificationBanner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDaltron%2FNotificationBanner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDaltron%2FNotificationBanner/lists"}