Retour au classement

candostdagdeviren/CDAlertView

Swiftcandostdagdeviren.github.io/CDAlertView/

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

popupalertalert-messagesalertviewalertswarningpopup-windowcarthagecocoapodsswift5
Croissance des étoiles
Étoiles
1.1k
Forks
84
Croissance hebdomadaire
Issues
4
6008001k
nov. 2016janv. 2020avr. 2023juil. 2026
README

CDAlertView: Highly customizable alert popup

Carthage compatible Cocoapod CI Status Language Platform License

CDAlertView is highly customizable alert popup written in Swift. Usage is similar to UIAlertController.

Screenshots

CDAlertView Types

Animations

1 2 3

Usage

Basic usage without any buttons:

CDAlertView(title: "Awesome Title", message: "Well explained message!", type: .notification).show()

NOTE: You can use it without buttons. Touch outside of the popup or move it will disappear it if there is no action button. If there is an action button, only pressing button will disappear it.

To add new buttons:

let alert = CDAlertView(title: "Awesome Title", message: "Are you in?!", type: .notification)
let doneAction = CDAlertViewAction(title: "Sure! 💪")
alert.add(action: doneAction)
let nevermindAction = CDAlertViewAction(title: "Nevermind 😑")
alert.add(action: nevermindAction)
alert.show()

To enable text field in popup:

alert.isTextFieldHidden = false

Custom view is also supported. If you want to use custom view, you are responsible for the height of custom view. Custom view is used in UIStackView.

let myCustomView = UIVIew(frame: myFrame)
// Don't forget to handle height of `myCustomView`
alert.customView = myCustomView

CDAlertView types:

public enum CDAlertViewType {
    case error, warning, success, notification, alarm, noImage, custom(image:UIImage)
}

Initialization

Advanced Alert Initialization

To use it with your custom icon, initialize without type (or with .empty) and set your icon and background color:

let alert = CDAlertView(title: "Awesome Title", message: "Well explained message!", type: .custom(image: UIImage(named:"YourAwesomeImage")))
alert.circleFillColor = UIColor.yourAmazingColor

Hide Alert with your animation

let alert = CDAlertView(title: "Awesome Title", message: "Well explained message!", type: .success)
alert.hideAnimations = { (center, transform, alpha) in
    transform = CGAffineTransform(scaleX: 3, y: 3)
    alpha = 0
}
alert.hideAnimationDuration = 0.88
alert.show()

Hide Alert with timer

let alert = CDAlertView(title: "Awesome Title", message: "Well explained message!", type: .success)
alert.autoHideTime = 4.5 // This will hide alert box after 4.5 seconds

List of Available CDAlertView Options

titleTextColor: UIColor -> Sets title's text color

messageTextColor: UIColor -> Sets message's text color

titleFont: UIFont -> Sets title's font

messageFont: UIFont -> Sets message's font

isHeaderIconFilled: Bool -> Chooses filled icons instead of outline ones. Default is false.

alertBackgroundColor: UIColor -> Sets popup's background color.

popupWidth: CGFloat -> Width of the popup view

hasRoundedCorners: Bool -> Apply rounded corners to alert view. Default is true.

hasShadow: Bool -> Apply shadows around the popup. Defualt is true.

circleFillColor: UIColor -> Sets background color of header icon. (Color of circle area)

isActionButtonsVertical: Bool -> Alignes action buttons vertical. Default is false. Maximum number of horizontal buttons is 3.

canHideWhenTapBack -> Hide self when tapped backgroundView. Default is false.

hideAnimationDuration: TimeInterval -> Sets the animation duration of hide animation

hideAnimations: CDAlertAnimationBlock -> Sets the hiding animations depending on the center, transform and alpha values. You can create your animations by changing these values for alert popup.

If you enabled text field with setting isTextFieldHidden property to false, following properties will be available also:

textFieldFont: UIFont -> Font of textField's text

textFieldIsSecureTextEntry: Bool -> Sets the isSecureTextEntry property of UITextField

textFieldReturnKeyType: UIReturnKeyType -> Sets the returnKeyType property of UITextField

textFieldTextAlignment: NSTextAlignment -> Sets the textAlignment property of UITextField. Default is .left.

textFieldPlaceholderText: String? -> Sets the placeholder text for UITextField.

textFieldAutocapitalizationType: UITextAutocapitalizationType -> Sets the autocapitalizationType property of UITextField. Default is .none.

textFieldBackgroundColor: UIColor -> Sets UITextField's background color.

textFieldTintColor: UIColor -> Sets UITextField's tint color.

textFieldText: String? -> Sets & gets UITextField's text.

textFieldHeight: CGFloat -> Sets the height of UITextField.

textFieldDelegate: UITextViewDelegate? -> Sets the delegate of UITextField. Default delegate is CDAlertView. If you overwrite this, you're responsible for resigning the UITextField.

autoHideTime: TimeInterval? -> Sets the time interval for dismiss time. Default is nil.

Advanced action initialization:

font, textColor, backgroundColor, handler are all optional and has default parameter values. You can initilize with them or set them after initialization.

let action = CDAlertViewAction(title: "Action Title", font: UIFont.yourCustomFont, textColor: UIColor.yourTextColor, backgroundColor: UIColor.yourBackgroundColor, handler: { action in })
alertView.addAction(action)

NOTE: Aligning buttons vertical and horizontal is possible. But using more than 3 buttons in horizontal placement is not possible.

List of CDAlertViewAction Options

buttonTitle: String -> Set's the action button title

buttonTextColor: UIColor -> Sets the action button title color. Default value is RGB(27,169,225).

buttonFont: UIFont -> Sets the action button title font. Default value is UIFont.systemFont(ofSize: 17).

buttonBackgroundColor: UIColor -> Sets the background color of action button. If not set, it uses alertBackgroundColor of CDAlertView.

List of available methods

textFieldBecomeFirstResponder() -> Calls the becomeFirstResponder() method of textField if alert.isTextFieldHidden set to true. Otherwise, does nothing.

textFieldResignFirstResponder() -> Calls the resignFirstResponder() method of textField if alert.isTextFieldHidden set to true. Otherwise, does nothing.

Example

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

Installation

This library supports Swift 5. Use 0.9.1 for Swift 4.2. Use 0.6.1 for Swift 3.1.

Using CocoaPods

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

pod "CDAlertView"

Using Carthage

CDAlertView is available through Carthage. To install it, simply add the following line to your Cartfile:

github "candostdagdeviren/CDAlertView"

Requirements

  • Xcode 9
  • Swift 4
  • iOS 9.0+

Icons

Thanks to Icons8 for beautiful icons.

License

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

Dépôts similaires
Semantic-Org/Semantic-UI

Semantic is a UI component framework based around useful principles from natural language.

JavaScriptnpmMIT Licenseuiui-components
semantic-ui.com
51k4.9k
t4t5/sweetalert

A beautiful replacement for JavaScript's "alert"

TypeScriptnpmMIT Licensemodalsweetalert
sweetalert.js.org
22.3k2.8k
sweetalert2/sweetalert2

✨ A beautiful, responsive, highly customizable and accessible (WAI-ARIA) replacement for JavaScript's popup boxes. Zero dependencies. 🇺🇦🇪🇺

JavaScriptnpmMIT Licensesweetalertalert
sweetalert2.github.io
18.1k1.6k
atomiks/tippyjs

Tooltip, popover, dropdown, and menu library

JavaScriptnpmMIT Licensetooltippopover
atomiks.github.io/tippyjs/
12.3k540
junixapp/XPopup

🔥XPopup2.0版本重磅来袭,2倍以上性能提升,带来可观的动画性能优化和交互细节的提升!!!功能强大,交互优雅,动画丝滑的通用弹窗!可以替代Dialog,PopupWindow,PopupMenu,BottomSheet,DrawerLayout,Spinner等组件,自带十几种效果良好的动画, 支持完全的UI和动画自定义!(Powerful and Beautiful Popup for Android,can absolutely replace Dialog,PopupWindow,PopupMenu,BottomSheet,DrawerLayout,Spinner. With built-in animators , very easy to custom popup view.)

JavaMavenApache License 2.0popupwindowbottomsheet
8k1.2k
huri000/SwiftEntryKit

SwiftEntryKit is a presentation library for iOS. It can be used to easily display overlays within your iOS apps.

SwiftMIT Licensebannerpopup
6.8k622
nextapps-de/winbox

WinBox is a modern HTML5 window manager for the Web.

JavaScriptnpmApache License 2.0windowwindowmanager
6.4k215
razerdp/BasePopup

Android下打造通用便捷的PopupWindow弹窗库

JavaMavenApache License 2.0popupwindowandroid
github.com/razerdp/BasePopup
5.3k763
Clooos/Bubble-Card

Bubble Card is a minimalist card collection for Home Assistant with a nice pop-up touch.

JavaScriptnpmMIT Licensecustom-cardcustom-cards
4.4k167
exyte/PopupView

Toasts and popups library written with SwiftUI

SwiftMIT Licenseswiftuiswiftui-framework
4.1k314
Orderella/PopupDialog

A simple, customizable popup dialog for iOS written in Swift. Replaces UIAlertController alert style.

SwiftOtherpopup-dialogpopup
mwfire.de
4k518
skydoves/Balloon

:balloon: Modernized and sophisticated tooltips, fully customizable with an arrow and animations for Android and Jetpack Compose.

KotlinApache License 2.0kotlinandroid
skydoves.github.io/Balloon/
4k310