All Projects → podkovyrin → Dwalertcontroller

podkovyrin / Dwalertcontroller

Licence: mit
UIAlertController re-implementation with controller containment support

Programming Languages

swift
15916 projects

Labels

Projects that are alternatives of or similar to Dwalertcontroller

Zingle
Zingle – An alert will display underneath your UINavigationBar 🎅
Stars: ✭ 109 (-63.42%)
Mutual labels:  alert
react-native-awesome-alert
🔔 Customizable modal components with ✔️check options in React Native
Stars: ✭ 50 (-83.22%)
Mutual labels:  alert
Devops Api
Golang + Beego 编写 提供开发/运维常用操作的HTTP API接口: 手机归属地查询、IP地址查询、工作日节假日判断、微信报警、钉钉报警、2步验证、密码存储、发送邮件、生成随机密码等功能
Stars: ✭ 258 (-13.42%)
Mutual labels:  alert
iakit
无依赖 mini 组件库,只封装了 alert, toast, loading, actionSheet 等使用频率较高的组件。适用于类似 H5 活动页的简单移动端项目,不必为了使用这些组件而引入一个大而全的 UI 库和框架。
Stars: ✭ 38 (-87.25%)
Mutual labels:  alert
weixin-alert
企业微信告警发送
Stars: ✭ 51 (-82.89%)
Mutual labels:  alert
Razor.SweetAlert2
A Razor class library for interacting with SweetAlert2
Stars: ✭ 98 (-67.11%)
Mutual labels:  alert
elastalert-operator
The Elastalert Operator is an implementation of a Kubernetes Operator, to easily integrate elastalert with gitops.
Stars: ✭ 18 (-93.96%)
Mutual labels:  alert
Prometheus
A docker-compose stack for Prometheus monitoring
Stars: ✭ 3,383 (+1035.23%)
Mutual labels:  alert
mobile-message
基于移动端的弹窗组件,默认提供info、success、warning、error、alert、confirm、multiple、vertical、bottomSheet、prompt,可自定义弹窗。它可以包含任何Html内容可以自定义弹窗的样式,也可以加入自定以的弹窗动画。
Stars: ✭ 13 (-95.64%)
Mutual labels:  alert
checkmk-telegram-notify
Get alerted by Check_MK via Telegram bash script
Stars: ✭ 28 (-90.6%)
Mutual labels:  alert
AlertBar
An easy alert on status bar
Stars: ✭ 64 (-78.52%)
Mutual labels:  alert
JDToaster
🍞 Toasty iOS alerts
Stars: ✭ 25 (-91.61%)
Mutual labels:  alert
MotionToastView
A Beautiful Multipurpose Motion Toast Library in iOS using Swift
Stars: ✭ 77 (-74.16%)
Mutual labels:  alert
PopOverAlert
PopOverAlert is a PopOver style alert view.
Stars: ✭ 56 (-81.21%)
Mutual labels:  alert
Rflutter alert
RFlutter Alert is super customizable and easy-to-use alert / popup dialog library for Flutter. You may create reusable alert styles or add buttons as much as you want with ease.
Stars: ✭ 271 (-9.06%)
Mutual labels:  alert
angular-8-alert-notifications
Angular 8 - Alert (Toaster) Notifications
Stars: ✭ 32 (-89.26%)
Mutual labels:  alert
BalloonPopup
Forget Android Toast! BalloonPopup displays a round or squared popup and attaches it to a View, like a callout. Uses the Builder pattern for maximum ease. The popup can automatically hide and can persist when the value is updated.
Stars: ✭ 32 (-89.26%)
Mutual labels:  alert
Tltransitions
快速实现控制器的转场和View的快速popover显示,并支持自定义动画、手势退场
Stars: ✭ 296 (-0.67%)
Mutual labels:  alert
Snackview
Customizable bottom-half alerts.
Stars: ✭ 280 (-6.04%)
Mutual labels:  alert
SpaceView
No description or website provided.
Stars: ✭ 58 (-80.54%)
Mutual labels:  alert

DWAlertController

CI Status Version Carthage Compatible Accio supported License Platform

When was the last time you told your designer you couldn't customize UIAlertController? Now it is possible. Without using any private API.

DWAlertController is an UIAlertController that supports displaying any view controller instead of title and message. DWAlertController fully copies the look and feel of UIAlertController and has the same API.

DWAlertController Screenshots

This alert successfully used in production in our app Dash Wallet.

Supported Features

  • iPhone / iPad compatible
  • Device rotations
  • Keyboard support
  • Customizable action buttons (normal / disabled / destructive tint colors)
  • Tap and slide over the action buttons
  • Custom presentation and dismissal transitions (corresponds to UIAlertController ones)
  • Dimming tintColor-ed views behind the alert
  • Simple built-in transition from one content controller to another within a single DWAlertController (see Advanced alert in the Example app)
  • Dynamic Type
  • Accessibility
  • Dark Mode and dark appearance for iOS 12 or lower

Usage

DWAlertController is written in Objective-C and optimized for Swift. All API that DWAlertController provides is the same as UIAlertController.

Swift

let controller = ... // instantiate view controller

let alert = DWAlertController(contentController: controller)

let okAction = DWAlertAction(title: NSLocalizedString("OK", comment: ""),
                             style: .cancel,
                             handler: nil)
alert.addAction(okAction)

present(alert, animated: true)

Objective-C

UIViewController *controller = ...; // instantiate view controller

DWAlertController *alert = [DWAlertController alertControllerWithContentController:controller];

DWAlertAction *okAction = [DWAlertAction actionWithTitle:NSLocalizedString(@"OK", nil)
                                                   style:DWAlertActionStyleCancel
                                                 handler:nil];
[alert addAction:okAction];

[self presentViewController:alert animated:YES completion:nil];

Important notice

To make DWAlertController works with a custom content controller, the view of the content controller must correctly implement Autolayout. You might have used the same technique when implementing dynamic-sized UITableViewCell's. For more information see https://stackoverflow.com/a/18746930

Since DWAlertController maintain scrolling of large content controllers internally (as UIAlertController does) there is no need in placing the content of content view controller within UIScrollView.

The backgroundColor of the content controller's view should be transparent (UIColor.clear).

Limitations

  • Only UIAlertController.Style.alert is supported (since there are a lot of decent implementations of actionSheet-styled controls)
  • Updating the height of the currently displaying view controller is not supported. However, when displaying a new controller with performTransition(toContentController:animated:) method, it may have a different height.

Requirements

iOS 9 or later.

Notes

The default UIAlertController achieves such vibrant and expressive background color by using the private CoreAnimation class CABackdropLayer which is lying within another private class _UIDimmingKnockoutBackdropView with UIVisualEffectView. This layer uses a CAFilter with "overlayBlendMode" to apply the effect to the view behind it. To get more information refer this answer.

As we wanted to use this alert in production we couldn't use any of those APIs. There are two possible options to get decent appearance comparable to using the private API.

  1. Make a screenshot of a view behind the alert and apply CIFilter with CIOverlayBlendMode to it. This approach results in the closest appearance to UIAlertController. However, there are several reasons why this approach cannot be used. Screenshotting during presentation adds a noticeable lag, neither it can't be done after presentation which might have led to blinking the content behind the alert. It would also have to take a screenshot when the user rotates the screen wich also lead to lags.
  2. Make a "hole" in the dimming view behind the alert and allow UIVisualEffectView to do all work. As a dimming view, we use CAShapeLayer with animatable path property to dynamically modify the "hole" during rotation or keyboard animation. While this is NOT a 100% smooth solution, it works almost perfectly and looks very close to UIAlertController.

All the colors and layout constants have been carefully copied from the UIAlertController.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation via CocoaPods

DWAlertController is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'DWAlertController'

Installation via Carthage

Carthage is a decentralized dependency manager that automates the process of adding frameworks to your Cocoa application.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate DWAlertController into your Xcode project using Carthage, specify it in your Cartfile:

github "podkovyrin/DWAlertController"

Installation via Accio

  1. Add the following to your Package.swift:
    .package(url: "https://github.com/podkovyrin/DWAlertController.git", .upToNextMajor(from: "0.2.1")),
    
  2. Next, add DWAlertController to your App targets dependencies like so:
    .target(name: "App", dependencies: ["DWAlertController"]),
    
  3. Then run accio update.

Author

Andrew Podkovyrin, [email protected]

License

DWAlertController is available under the MIT license. See the LICENSE file for more info.

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].