All Projects → KyoheiG3 → Simplealert

KyoheiG3 / Simplealert

Licence: mit
Customizable simple Alert and simple ActionSheet for Swift

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Simplealert

mr-brown
Mr.Brown is a responsive Jekyll theme
Stars: ✭ 21 (-94.53%)
Mutual labels:  customizable
Epiboard
Web Extension — A new tab page extension with material design and useful features 🆕 🎉
Stars: ✭ 262 (-31.77%)
Mutual labels:  customizable
Appupdate
🚀 Android 版本更新 🚀 a library for android version update 🚀
Stars: ✭ 3,375 (+778.91%)
Mutual labels:  customizable
nuclear
Polymorphic and Multilingual CMS powered by Laravel
Stars: ✭ 31 (-91.93%)
Mutual labels:  customizable
Welcome Ui
Customizable design system of @wttj with react • styled-components • styled-system • reakit
Stars: ✭ 256 (-33.33%)
Mutual labels:  customizable
Furo
A clean customizable documentation theme for Sphinx
Stars: ✭ 267 (-30.47%)
Mutual labels:  customizable
badaso
The API & platform builder, build your apps 10x faster even more, it's open source & 100% free !
Stars: ✭ 650 (+69.27%)
Mutual labels:  customizable
Tkimageview
An easy way to crop an image.
Stars: ✭ 342 (-10.94%)
Mutual labels:  customizable
Incrementproductview
Interesting concept of products incrementation
Stars: ✭ 262 (-31.77%)
Mutual labels:  customizable
Autocomplete.js
Simple autocomplete pure vanilla Javascript library.
Stars: ✭ 3,428 (+792.71%)
Mutual labels:  customizable
plain-overlay
The simple library for customizable overlay which covers a page, elements or iframe-windows.
Stars: ✭ 28 (-92.71%)
Mutual labels:  customizable
React Custom Scrollbars
React scrollbars component
Stars: ✭ 2,924 (+661.46%)
Mutual labels:  customizable
Uumarqueeview
[iOS]Customizable marquee view. #Marquee,MarqueeView,跑马灯,滚屏,上翻,左滑,多行,自定义
Stars: ✭ 295 (-23.18%)
Mutual labels:  customizable
slimline
Minimal, customizable, fast and elegant ZSH prompt
Stars: ✭ 48 (-87.5%)
Mutual labels:  customizable
Vue Simple Suggest
Feature-rich autocomplete component for Vue.js
Stars: ✭ 324 (-15.62%)
Mutual labels:  customizable
MinTimetable
Customizable TimeTableView for Android
Stars: ✭ 26 (-93.23%)
Mutual labels:  customizable
Sleek circular slider
Sleek circular slider for Flutter
Stars: ✭ 269 (-29.95%)
Mutual labels:  customizable
Pegasus Frontend
A cross platform, customizable graphical frontend for launching emulators and managing your game collection.
Stars: ✭ 364 (-5.21%)
Mutual labels:  customizable
Horizontalpicker
A simple, customizable and easy to use picker where centre view is scaled up
Stars: ✭ 337 (-12.24%)
Mutual labels:  customizable
Timestamp
⏰ A better macOS menu bar clock.
Stars: ✭ 296 (-22.92%)
Mutual labels:  customizable

SimpleAlert

Carthage compatible Version License Platform

It is simple and easily customizable alert. Can be used as UIAlertController.

Appetize's Demo

default_view custom_view custom_content rounded_view

Requirements

  • Swift 5.0
  • iOS 9.0 or later

How to Install SimpleAlert

Cocoapods

Add the following to your Podfile:

pod "SimpleAlert"

Carthage

Add the following to your Cartfile:

github "KyoheiG3/SimpleAlert"

Usage

Example

View simple Alert

let alert = AlertController(title: "title", message: "message", style: .alert)

alert.addTextField()
alert.addAction(AlertAction(title: "Cancel", style: .cancel))
alert.addAction(AlertAction(title: "OK", style: .ok))

present(alert, animated: true, completion: nil)

Customize default contents

let alert = AlertController(title: "title", message: "message", style: .alert)
alert.addTextField { textField in
    textField.frame.size.height = 33
    textField.backgroundColor = nil
    textField.layer.borderColor = nil
    textField.layer.borderWidth = 0
}
alert.configureContentView { view in
    view.titleLabel.textColor = UIColor.lightGrayColor()
    view.titleLabel.font = UIFont.boldSystemFontOfSize(30)
    view.messageLabel.textColor = UIColor.lightGrayColor()
    view.messageLabel.font = UIFont.boldSystemFontOfSize(16)
    view.textBackgroundView.layer.cornerRadius = 3.0
    view.textBackgroundView.clipsToBounds = true
}

alert.addAction(AlertAction(title: "Cancel", style: .cancel))
alert.addAction(AlertAction(title: "OK", style: .ok))
present(alert, animated: true, completion: nil)

Rounded button Alert View

let alert = AlertController(view: UIView(), style: .alert)
alert.contentWidth = 144
alert.contentCornerRadius = 72
alert.contentColor = .white
let action = AlertAction(title: "?", style: .cancel) { action in
}

alert.addAction(action)
action.button.frame.size.height = 144
action.button.titleLabel?.font = UIFont.boldSystemFont(ofSize: 96)
action.button.setTitleColor(UIColor.red, for: .normal)

present(alert, animated: true, completion: nil)

More customizable if you create a subclass

class CustomAlertController: AlertController {
    override func addTextField(configurationHandler: ((UITextField) -> Void)? = nil) {
        super.addTextField { textField in
            textField.frame.size.height = 33
            textField.backgroundColor = nil
            textField.layer.borderColor = nil
            textField.layer.borderWidth = 0

            configurationHandler?(textField)
        }
    }

    override func configureActionButton(_ button: UIButton, at style :AlertAction.Style) {
        super.configureActionButton(button, at: style)

        switch style {
        case .ok:
            button.titleLabel?.font = UIFont.boldSystemFont(ofSize: 20)
            button.setTitleColor(UIColor.gray, for: UIControlState())
        case .cancel:
            button.backgroundColor = UIColor.darkGray
            button.setTitleColor(UIColor.white, for: UIControlState())
        case .default:
            button.setTitleColor(UIColor.lightGray, for: UIControlState())
        default:
            break
        }
    }

    override func configureContentView(_ contentView: AlertContentView) {
        super.configureContentView(contentView)

        contentView.titleLabel.textColor = UIColor.lightGray
        contentView.titleLabel.font = UIFont.boldSystemFont(ofSize: 30)
        contentView.messageLabel.textColor = UIColor.lightGray
        contentView.messageLabel.font = UIFont.boldSystemFont(ofSize: 16)
        contentView.textBackgroundView.layer.cornerRadius = 10.0
        contentView.textBackgroundView.clipsToBounds = true
    }
}

Class

AlertAction

Style

  • default
  • ok
  • cancel
  • destructive

Initialize

init(title: String, style: SimpleAlert.AlertAction.Style, dismissesAlert: Bool = default, handler: ((SimpleAlert.AlertAction?) -> Swift.Void)? = default)
  • Set title and style, can add button.
  • Set button action handler.

Variable

var isEnabled: Bool
  • Set button enabled.
let button: UIButton
  • Can get a button.
  • Can get after button has been added to the AlertController.

AlertContentView

backgroundColor of AlertContentView will be reflected in the overall backgroundColor.

var baseView: UIView!
  • Base view for contents
var titleLabel: UILabel!
  • Title label
var messageLabel: UILabel!
  • Message Label
var textBackgroundView: UIView!
  • Base view for Text Field
  • UIAlertControllerStyle is in the case of actionSheet does not appear.

AlertController

Initialize

init(title: String?, message: String?, style: UIAlertControllerStyle)
  • Set title, message and style, can add button.
  • Set button action handler.
init(title: String? = default, message: String? = default, view: UIView?, style: UIAlertControllerStyle)
  • Can also set custom view.

Variable

open var contentWidth: CGFloat
open var contentColor: UIColor?
open var contentCornerRadius: CGFloat?
open var coverColor: UIColor
open var message: String?
  • Can change alert style.
public private(set) var actions: [SimpleAlert.AlertAction]
public var textFields: [UITextField] { get }
  • Can get actions and text fields that is added.

Function

func addTextField(configurationHandler: ((UITextField) -> Swift.Void)? = default)
  • Add Text Field, and set handler.
  • UIAlertControllerStyle is in the case of actionSheet does not add.
func addAction(_ action: SimpleAlert.AlertAction)
  • Add action button.
func configureActionButton(_ button: UIButton, at style: SimpleAlert.AlertAction.Style)
  • Override if would like to configure action button.
func configureContentView(_ contentView: SimpleAlert.AlertContentView)
  • Override if would like to configure content view.

The difference between default UIAlertController

  • Can add a cancel button any number of the actionSheet.
  • If tap the outside of the view, the action handler will not be executed of the actionSheet.

Author

Kyohei Ito

Follow me 🎉

LICENSE

Under the MIT license. See LICENSE file for details.

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