A Simple And Minimalist iOS AlertController

Overview

HYAlertController

Language GitHub license Pod version

HYAlertController is a minimalist alert control, that contains a variety of usage scenarios. It has the same syntax as Apple's UIAlertController, so you can easily use it in your own app.

中文说明

Alert Style

Icon

Icon

Sheet Style

Icon

Icon

Share Style

Icon

Features

  • Title
  • Description message(adaptive height)
  • Button with icon
  • The default has the cancel button
  • New share style
  • Closure when a button is clicked
  • Similar syntax to UIAlertController
  • Swift 3 support
  • Cocoapods
  • Carthage

Requirements

  • Swift 3
  • iOS 10.0+
  • Xcode 8+

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

Then create Podfile file into your Xcode project, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!

pod 'HYAlertController'

Finially, you will complete it with the following command:

$ pod install

Manually

Download and drop /HYAlertController folder in your project.

Usage

The usage is very similar to UIAlertController. HYAlertController has three styles: Alert, Sheet and Share.

Alert Style: with this style, you can center the contents of the display as a reminder to the user operation of the dialog box;

Sheet Style: with this style, you can display the contents of the bottom of the screen, the following will pop up a dialog box for the user to select;

Share Style: similar to Sheet Style, the difference is that this style can be used for sharing, you can quickly complete the creation of mainstream sharing style.

Alert Style

//Work with Swift 3

let alertVC: HYAlertController = HYAlertController (title: "Title", message: "Here you can describe the details of its title, and you can write here what you want to express.", style: .alert)
let oneAction: HYAlertAction = HYAlertAction (title: "One Action", style: .normal, handler:  { (action) in
    print(action.title)
})
let twoAction: HYAlertAction = HYAlertAction (title: "Two Action", style: .normal, handler:  { (action) in
    print(action.title)
})
let threeAction: HYAlertAction = HYAlertAction (title: "Three Action", style: .destructive, handler:  { (action) in
    print(action.title)
})
let cancelAction: HYAlertAction = HYAlertAction (title: "Cancel Action", style: .cancel, handler:  { (action) in
    print(action.title)
})
alertVC.addAction(action: oneAction)
alertVC.addAction(action: twoAction)
alertVC.addAction(action: threeAction)
alertVC.addAction(action: cancelAction)
self.present(alertVC, animated: true, completion: nil)

Sheet Style

//Work with Swift 3

let alertVC: HYAlertController = HYAlertController (title: "Title", message: "Here you can describe the details of its title, and you can write here what you want to express.", style: .actionSheet)
let oneAction: HYAlertAction = HYAlertAction (title: "One Action", style: .normal, handler:  { (action) in
    print(action.title)
})
let twoAction: HYAlertAction = HYAlertAction (title: "Two Action", style: .normal, handler:  { (action) in
    print(action.title)
})
let threeAction: HYAlertAction = HYAlertAction (title: "Three Action", style: .destructive, handler:  { (action) in
    print(action.title)
})
let cancelAction: HYAlertAction = HYAlertAction (title: "Cancel Action", style: .cancel, handler:  { (action) in
    print(action.title)
})
alertVC.addAction(action: oneAction)
alertVC.addAction(action: twoAction)
alertVC.addAction(action: threeAction)
alertVC.addAction(action: cancelAction)
self.present(alertVC, animated: true, completion: nil)

Share Style

//Work with Swift 3
let alertVC: HYAlertController = HYAlertController (title: nil, message: nil, style: .shareSheet)
let oneAction: HYAlertAction = HYAlertAction (title: "Facebook", image: UIImage (named: "facebook")!, style: .normal, handler: {
            (action) in
    print(action.title)
})
let twoAction: HYAlertAction = HYAlertAction (title: "Twitter", image: UIImage (named: "twitter")!, style: .normal, handler: {
            (action) in
    print(action.title)
})
let threeAction: HYAlertAction = HYAlertAction (title: "Snapchat", image: UIImage (named: "snapchat")!, style: .normal, handler: {
            (action) in
    print(action.title)
})
let fourAction: HYAlertAction = HYAlertAction (title: "Instagram", image: UIImage (named: "instagram")!, style: .normal, handler: {
            (action) in
    print(action.title)
})
let fiveAction: HYAlertAction = HYAlertAction (title: "Pinterest", image: UIImage (named: "pinterest")!, style: .normal, handler: {
            (action) in
    print(action.title)
})
let sixAction: HYAlertAction = HYAlertAction (title: "Line", image: UIImage (named: "line")!, style: .normal, handler: {
            (action) in
    print(action.title)
})
alertVC.addShareActions(actions: [oneAction, twoAction, threeAction, fourAction, fiveAction, sixAction])
self.present(alertVC, animated: true, completion: nil)

For more usage scenarios, please refer to HYAlertControllerDemo for details.

Swift Version

HYAlertController is developed with Swift 3, so your Swift version must be Swift 3.

Custom

HYAlertController does not provide customization outside, which is related to the developer's idea. If you want to make some basic changes, download the project source and modify theHY_Constants.swift file, which contains some basic setting constants, modify it.

After modification, you can integrate into your project using the above manual installation method.

Communicate

  • If you need help or you'd like to ask a general question, open an issue;
  • If you found a bug, open an issue;
  • If you have a feature request, open an issue;
  • If you want to contribute, submit a pull request.

MIT License

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

Comments
  • Share item button icon and title issue

    Share item button icon and title issue

    There is a bug. When i scrolled the collectionCell,the cell's button icon and title's position has changed, the button's imageSize is not stable,when it scrolled can be changed,look like a reuse issue or image's size relatived.please check and fix it。

    bug 
    opened by yvanda 2
  • 旋转屏幕的时候, 遮罩视图只遮住了一般。

    旋转屏幕的时候, 遮罩视图只遮住了一般。

    snip20161215_23

    1. 使用了三个 tableview . 可以考虑一下是否方案太臃肿。 可以考虑 UIStackView
    2. 三个弹出视图可以抽取一个父类出来。 这样可以省去很多代码
    3. HY_Constants 没有必要继承自 UIView . HY_Constants 没有用到 UIView 的任何东西。 单纯是一个工具类,不考虑继承可以使用结构体。
    4. 内部布局用到了 SnapKit lib . 从你布局代码的书写来看。 你可以自己以系统 autolayout 为基础写几个加约束的工具方法。(不是特别依赖其他第三方库,不建议在自己的第三方库中使用第三方库) 只有 HYAlertCell 和 HYShareCollectionCell 中的少量布局代码使用了 SnapKit
    opened by laughingg 1
  • 毛玻璃

    毛玻璃

    你好,愿不愿意跟我一起探讨一下对话框的毛玻璃问题呢?因为我发现无论是系统,还是微信,微博等,它们的毛玻璃都很漂亮。我说的漂亮是什么意思呢,意思就是毛玻璃不会受到蒙板的影响,我看你的蒙板设置的alpha值是0.3,其实0.3过低了,系统设置的是黑色0.4透明,我看过系统的层级关系图,毛玻璃并未受到蒙板的任何影响,我自己最近也封装了一个https://github.com/SPStore/SPAlertController。 但是不管我怎么设置毛玻璃,因为蒙层的影响,都会偏黑色,我看你的也同样如此。这个问题我已经想了几天几夜了,网上找资料也没人解决过,其实用第三方不是不能实现,但是我不想依赖第三方,而且系统用的也是iOS8自带的UIBlurEffect,只是我不知道系统是如何做到的,我想过用运行时去交换UIVisualEffectView的某个方法,但那么多私有方法,我也不知该重写哪一个。 微信微博和系统的毛玻璃效果都是一致的,能否一起研究一下,我实在遇到困难了。

    opened by SPStore 1
  • Error when attempting to create a share sheet

    Error when attempting to create a share sheet

    I have taken exactly what you had written for the share controller and imported HYAlertController into my project. It gives me the error 'HYAlertController' initializer is inaccessible due to 'internal' protection level

    opened by Srosman 0
  • The dismiss animation disappeared immediately.

    The dismiss animation disappeared immediately.

    I found a issue, the dismiss animation disappeared immediately when tapped the action button, but the present animation is ok, the animation duration is both set to 0.5.Please check it.

    opened by yvanda 0
Releases(1.0.2)
Owner
null
Swift AlertController with UIVisualeffectview

PCLBlurEffectAlert Swift AlertController, use UIVisualeffectview Requirements iOS 8.0+ Swift 3.0+ ARC Feature Change color Change effect Change font U

Hiroyuki Yoshida 147 Jun 29, 2022
Customizable simple Alert and simple ActionSheet for Swift

SimpleAlert It is simple and easily customizable alert. Can be used as UIAlertController. Appetize's Demo Requirements Swift 5.0 iOS 9.0 or later How

Kyohei Ito 397 Dec 6, 2022
🌊 - Jelly is a library for animated, non-interactive & interactive viewcontroller transitions and presentations with the focus on a simple and yet flexible API.

Jelly is a library for animated, non-interactive & interactive viewcontroller transitions and presentations with the focus on a simple and yet flexibl

Sebastian Boldt 2.4k Dec 25, 2022
zekunyan 608 Dec 30, 2022
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
Whisper is a component that will make the task of display messages and in-app notifications simple. It has three different views inside

Description ?? Break the silence of your UI, whispering, shouting or whistling at it. Whisper is a component that will make the task of displaying mes

HyperRedink 3.7k Dec 25, 2022
AlertView A pop-up framework, Can be simple and convenient to join your project.

RAlertView AlertView A pop-up framework, Can be simple and convenient to join your project. Warning content Installation Depend on the project Masonry

杜耀辉 71 Aug 12, 2022
A simple and attractive AlertView to ask permission to your users for Push Notification.

A simple and attractive AlertView **to ask permission to your users for Push Notification.** PRESENTATION Ask permission to user for push notification

Boisney Philippe 37 Mar 23, 2022
A simple alert with logo image and color.

YMLogoAlert About YMLogoAlert A simple custom alert. YMLogoAlert lets you pop up a simple alert with a natural animation, your app's own color, font a

Youngminah 8 Dec 21, 2022
Simple and elegant way to handle UIAlertController.

SwiftyAlert SwiftAlert is simple and elegant way to handle UIAlertController. Feature Handle action with async/await Method chain Support UITextField

Jaesung Jung 2 Oct 30, 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
iOS / Objective C: an extremely simple UIAlertView alternative

RKDropdownAlert an extremely simple (and customizeable) alert alternative based on Facebook's app Slingshot, and inspiration from SVProgressHUD (yes,

Richard Kim 1.5k Nov 20, 2022
Simple DropDown Alert View For Any iOS Projects.

⚠️ DEPRECATED, NO LONGER MAINTAINED JDropDownAlert JDropDownALert Simple DropDown Alert View For Any iOS Projects. Usage Top let alert = JDropDown

WonJo 71 Jul 17, 2022
A Simple Toast Library for iOS

PowerplayToastKit Toasts Type Success. Warning Error Info Custom View (Dialog) Example To run the example project, clone the repo, and run pod install

Mithilesh Parmar 18 Jul 2, 2022
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.

donggyu 5 Jan 26, 2022
A simple style messages/notifications, in Swift.

Demo Example To show notifications use the following code: self.showMessage("Something success", type: .success) To display a notice on a view: view.s

Gesen 704 Dec 17, 2022
Simple UIAlertController builder class in Swift.

Kamagari Simple UIAlertController builder class in Swift. Features AlertBuilder class to simply build UIAlertController by using method chaining UIAle

Kazunobu Tasaka 78 Nov 29, 2022
BottomSheet makes it easy to take advantage of the new UISheetPresentationController in SwiftUI with a simple .bottomSheet modifier on existing views.

BottomSheet makes it easy to take advantage of the new UISheetPresentationController in SwiftUI with a simple .bottomSheet modifier on existing views.

Adam Foot 341 Dec 15, 2022
😍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

Qiun Cheng 235 Sep 9, 2022