{"id":2420,"url":"https://github.com/KyoheiG3/SimpleAlert","last_synced_at":"2025-08-02T23:33:30.418Z","repository":{"id":25575459,"uuid":"29009301","full_name":"KyoheiG3/SimpleAlert","owner":"KyoheiG3","description":"Customizable simple Alert and simple ActionSheet for Swift","archived":false,"fork":false,"pushed_at":"2023-09-07T10:25:10.000Z","size":175,"stargazers_count":399,"open_issues_count":2,"forks_count":45,"subscribers_count":17,"default_branch":"master","last_synced_at":"2024-04-24T14:48:20.803Z","etag":null,"topics":["customizable","ios","simplealert","swift"],"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/KyoheiG3.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2015-01-09T09:14:01.000Z","updated_at":"2024-04-24T14:48:20.804Z","dependencies_parsed_at":"2024-01-02T21:14:36.809Z","dependency_job_id":"4284a442-6e98-4320-9ab5-55261385c125","html_url":"https://github.com/KyoheiG3/SimpleAlert","commit_stats":null,"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KyoheiG3%2FSimpleAlert","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KyoheiG3%2FSimpleAlert/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KyoheiG3%2FSimpleAlert/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KyoheiG3%2FSimpleAlert/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KyoheiG3","download_url":"https://codeload.github.com/KyoheiG3/SimpleAlert/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228503208,"owners_count":17930538,"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":["customizable","ios","simplealert","swift"],"created_at":"2024-01-05T20:16:13.331Z","updated_at":"2024-12-06T17:31:05.021Z","avatar_url":"https://github.com/KyoheiG3.png","language":"Swift","readme":"# SimpleAlert\n\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![Version](https://img.shields.io/cocoapods/v/SimpleAlert.svg?style=flat)](http://cocoapods.org/pods/SimpleAlert)\n[![License](https://img.shields.io/cocoapods/l/SimpleAlert.svg?style=flat)](http://cocoapods.org/pods/SimpleAlert)\n[![Platform](https://img.shields.io/cocoapods/p/SimpleAlert.svg?style=flat)](http://cocoapods.org/pods/SimpleAlert)\n\nIt is simple and easily customizable alert.\nCan be used as `UIAlertController`.\n\n#### [Appetize's Demo](https://appetize.io/app/w12zxu30gtr8p5a7v9t37gmzp4)\n\n\u003cp\u003e\u003cimg src=\"https://user-images.githubusercontent.com/5707132/33262364-56970b8c-d3a9-11e7-8f2d-54b8865bf396.png\" alt=\"default_view\" width=\"150\" /\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/5707132/33262361-56423fd0-d3a9-11e7-8e81-a022b33e02a9.png\" alt=\"custom_view\" width=\"150\" /\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/5707132/33262360-56206446-d3a9-11e7-9d30-f998f5d1b041.png\" alt=\"custom_content\" width=\"150\" /\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/5707132/33262365-56b85bb6-d3a9-11e7-9a6b-aa933cd2a7e2.png\" alt=\"rounded_view\" width=\"150\" /\u003e\u003c/p\u003e\n\n## Requirements\n\n- Swift 5.0\n- iOS 9.0 or later\n\n## How to Install SimpleAlert\n\n#### Cocoapods\n\nAdd the following to your `Podfile`:\n\n```Ruby\npod \"SimpleAlert\"\n```\n\n#### Carthage\n\nAdd the following to your `Cartfile`:\n\n```Ruby\ngithub \"KyoheiG3/SimpleAlert\"\n```\n\n## Usage\n\n### Example\n\nView simple Alert\n\n```Swift\nlet alert = AlertController(title: \"title\", message: \"message\", style: .alert)\n\nalert.addTextField()\nalert.addAction(AlertAction(title: \"Cancel\", style: .cancel))\nalert.addAction(AlertAction(title: \"OK\", style: .ok))\n\npresent(alert, animated: true, completion: nil)\n```\n\nCustomize default contents\n\n```Swift\nlet alert = AlertController(title: \"title\", message: \"message\", style: .alert)\nalert.addTextField { textField in\n    textField.frame.size.height = 33\n    textField.backgroundColor = nil\n    textField.layer.borderColor = nil\n    textField.layer.borderWidth = 0\n}\nalert.configureContentView { view in\n    view.titleLabel.textColor = UIColor.lightGrayColor()\n    view.titleLabel.font = UIFont.boldSystemFontOfSize(30)\n    view.messageLabel.textColor = UIColor.lightGrayColor()\n    view.messageLabel.font = UIFont.boldSystemFontOfSize(16)\n    view.textBackgroundView.layer.cornerRadius = 3.0\n    view.textBackgroundView.clipsToBounds = true\n}\n\nalert.addAction(AlertAction(title: \"Cancel\", style: .cancel))\nalert.addAction(AlertAction(title: \"OK\", style: .ok))\npresent(alert, animated: true, completion: nil)\n\n```\n\nRounded button Alert View\n\n```Swift\nlet alert = AlertController(view: UIView(), style: .alert)\nalert.contentWidth = 144\nalert.contentCornerRadius = 72\nalert.contentColor = .white\nlet action = AlertAction(title: \"?\", style: .cancel) { action in\n}\n\nalert.addAction(action)\naction.button.frame.size.height = 144\naction.button.titleLabel?.font = UIFont.boldSystemFont(ofSize: 96)\naction.button.setTitleColor(UIColor.red, for: .normal)\n\npresent(alert, animated: true, completion: nil)\n```\n\nMore customizable if you create a subclass\n\n```Swift\nclass CustomAlertController: AlertController {\n    override func addTextField(configurationHandler: ((UITextField) -\u003e Void)? = nil) {\n        super.addTextField { textField in\n            textField.frame.size.height = 33\n            textField.backgroundColor = nil\n            textField.layer.borderColor = nil\n            textField.layer.borderWidth = 0\n\n            configurationHandler?(textField)\n        }\n    }\n\n    override func configureActionButton(_ button: UIButton, at style :AlertAction.Style) {\n        super.configureActionButton(button, at: style)\n\n        switch style {\n        case .ok:\n            button.titleLabel?.font = UIFont.boldSystemFont(ofSize: 20)\n            button.setTitleColor(UIColor.gray, for: UIControlState())\n        case .cancel:\n            button.backgroundColor = UIColor.darkGray\n            button.setTitleColor(UIColor.white, for: UIControlState())\n        case .default:\n            button.setTitleColor(UIColor.lightGray, for: UIControlState())\n        default:\n            break\n        }\n    }\n\n    override func configureContentView(_ contentView: AlertContentView) {\n        super.configureContentView(contentView)\n\n        contentView.titleLabel.textColor = UIColor.lightGray\n        contentView.titleLabel.font = UIFont.boldSystemFont(ofSize: 30)\n        contentView.messageLabel.textColor = UIColor.lightGray\n        contentView.messageLabel.font = UIFont.boldSystemFont(ofSize: 16)\n        contentView.textBackgroundView.layer.cornerRadius = 10.0\n        contentView.textBackgroundView.clipsToBounds = true\n    }\n}\n```\n\n## Class\n\n### AlertAction\n\n#### Style\n\n- default\n- ok\n- cancel\n- destructive\n\n#### Initialize\n\n```Swift\ninit(title: String, style: SimpleAlert.AlertAction.Style, dismissesAlert: Bool = default, handler: ((SimpleAlert.AlertAction?) -\u003e Swift.Void)? = default)\n```\n- Set title and style, can add button.\n- Set button action handler.\n\n#### Variable\n\n```Swift\nvar isEnabled: Bool\n```\n- Set button enabled.\n\n```Swift\nlet button: UIButton\n```\n- Can get a button.\n- Can get after button has been added to the `AlertController`.\n\n### AlertContentView\n\n`backgroundColor` of `AlertContentView` will be reflected in the overall `backgroundColor`.\n\n```Swift\nvar baseView: UIView!\n```\n- Base view for contents\n\n```Swift\nvar titleLabel: UILabel!\n```\n- Title label\n\n```Swift\nvar messageLabel: UILabel!\n```\n- Message Label\n\n```Swift\nvar textBackgroundView: UIView!\n```\n- Base view for Text Field\n- `UIAlertControllerStyle` is in the case of `actionSheet` does not appear.\n\n### AlertController\n\n#### Initialize\n\n```Swift\ninit(title: String?, message: String?, style: UIAlertControllerStyle)\n```\n- Set title, message and style, can add button.\n- Set button action handler.\n\n```Swift\ninit(title: String? = default, message: String? = default, view: UIView?, style: UIAlertControllerStyle)\n```\n- Can also set custom view.\n\n#### Variable\n\n```Swift\nopen var contentWidth: CGFloat\nopen var contentColor: UIColor?\nopen var contentCornerRadius: CGFloat?\nopen var coverColor: UIColor\nopen var message: String?\n```\n- Can change alert style.\n\n```Swift\npublic private(set) var actions: [SimpleAlert.AlertAction]\npublic var textFields: [UITextField] { get }\n```\n- Can get actions and text fields that is added.\n\n#### Function\n\n```Swift\nfunc addTextField(configurationHandler: ((UITextField) -\u003e Swift.Void)? = default)\n```\n\n- Add Text Field, and set handler.\n- `UIAlertControllerStyle` is in the case of `actionSheet` does not add.\n\n```Swift\nfunc addAction(_ action: SimpleAlert.AlertAction)\n```\n- Add action button.\n\n```Swift\nfunc configureActionButton(_ button: UIButton, at style: SimpleAlert.AlertAction.Style)\n```\n- Override if would like to configure action button.\n\n```Swift\nfunc configureContentView(_ contentView: SimpleAlert.AlertContentView)\n```\n- Override if would like to configure content view.\n\n## The difference between default `UIAlertController`\n\n- Can add a cancel button any number of the `actionSheet`.\n- If tap the outside of the view, the action handler will not be executed of the `actionSheet`.\n\n## Author\n\n#### Kyohei Ito\n\n- [GitHub](https://github.com/kyoheig3)\n- [Twitter](https://twitter.com/kyoheig3)\n\nFollow me 🎉\n\n## LICENSE\n\nUnder the MIT license. See [LICENSE](./LICENSE) file for details.\n","funding_links":[],"categories":["UI"],"sub_categories":["Alert \u0026 Action Sheet","Other free courses"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKyoheiG3%2FSimpleAlert","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FKyoheiG3%2FSimpleAlert","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKyoheiG3%2FSimpleAlert/lists"}