{"id":13995089,"url":"https://github.com/dinhquan/SwiftAlertView","last_synced_at":"2025-07-22T21:32:00.117Z","repository":{"id":43771766,"uuid":"41553277","full_name":"dinhquan/SwiftAlertView","owner":"dinhquan","description":"A powerful AlertView library written in Swift","archived":false,"fork":false,"pushed_at":"2023-10-30T07:42:26.000Z","size":765,"stargazers_count":300,"open_issues_count":4,"forks_count":34,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-20T19:02:31.404Z","etag":null,"topics":["alert","carthage","cocoapods","customize","ios","popup","swift","swift-package-manager","swiftui","uialertcontroller","uialertview","uikit"],"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/dinhquan.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-08-28T15:01:10.000Z","updated_at":"2024-11-11T11:22:31.000Z","dependencies_parsed_at":"2024-01-18T05:21:46.965Z","dependency_job_id":"ad8f0a83-20a0-40c1-a9d7-bd6223343e46","html_url":"https://github.com/dinhquan/SwiftAlertView","commit_stats":{"total_commits":60,"total_committers":5,"mean_commits":12.0,"dds":"0.41666666666666663","last_synced_commit":"501f3adf5e9663763b7eb8726740a74116cd9dfd"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dinhquan%2FSwiftAlertView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dinhquan%2FSwiftAlertView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dinhquan%2FSwiftAlertView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dinhquan%2FSwiftAlertView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dinhquan","download_url":"https://codeload.github.com/dinhquan/SwiftAlertView/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227177757,"owners_count":17743159,"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":["alert","carthage","cocoapods","customize","ios","popup","swift","swift-package-manager","swiftui","uialertcontroller","uialertview","uikit"],"created_at":"2024-08-09T14:03:14.755Z","updated_at":"2024-11-29T17:30:57.099Z","avatar_url":"https://github.com/dinhquan.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"SwiftAlertView\n===========\n\nA powerful customizable Alert View library written in Swift.\n\n`SwiftAlertView` is the best alternative for `UIAlertController` and `SwiftUI alert`.\nWith `SwiftAlertView`, you can easily make your desired Alert View in some lines of code.\n\n![](https://raw.githubusercontent.com/dinhquan/SwiftAlertView/master/SwiftAlertView/Images/demo.png)\n\n## Highlight Features\n\n| Features  | SwiftAlertView | UIAlertController |\n| - | - | - |\n| Change button color | :white_check_mark: | :white_check_mark: |\n| Change button font | :white_check_mark: | :x: |\n| Change title, message color/font | :white_check_mark: | :x: |\n| Change title, message margin | :white_check_mark: | :x: |\n| Change background color/image | :white_check_mark: | :x: |\n| Change dim background color | :white_check_mark: | :x: |\n| Change border radius, separator color | :white_check_mark: | :x: |\n| Dark mode | :white_check_mark: | :white_check_mark: |\n| Add text fields | :white_check_mark: | :white_check_mark: |\n| Callback for handling text changed | :white_check_mark: | :x:  |\n| Init alert with custom view/xib file | :white_check_mark: | :x:  |\n| TextField Validation Label | :white_check_mark: | :x:  |\n| Customize transtion type | :white_check_mark: | :x:  |\n| Easy-to-use APIs | Super easy | Not so easy |\n\n## Installation\n\n#### CocoaPods\n\n```ruby\npod 'SwiftAlertView', '~\u003e 2.2.1'\n```\n\n#### Carthage\n\n```ogdl\ngithub \"https://github.com/dinhquan/SwiftAlertView\" ~\u003e 2.2.1\n```\n\n#### Swift Package Manager\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/dinhquan/SwiftAlertView\", .upToNextMajor(from: \"2.2.1\"))\n]\n```\n\n#### Manually\nDrag and drop the file named ```SwiftAlertView``` inside `Source` in your project and you are done.\n\n## Usage\n\n### Showing alert\n\n```swift\nSwiftAlertView.show(title: \"Title\", message: \"Message\", buttonTitles: \"Cancel\", \"OK\")\n```\n\nCustomization\n\n```swift\nSwiftAlertView.show(title: \"Title\",\n                    message: \"Message\",\n                    buttonTitles: \"OK\", \"Cancel\") { alert in\n    alert.backgroundColor = .yellow\n    alert.cancelButtonIndex = 1\n    alert.buttonTitleColor = .blue\n}\n```\n\nHandle button clicked events\n\n```swift\nSwiftAlertView.show(title: \"Title\",\n                    message: \"Message\",\n                    buttonTitles: \"Cancel\", \"OK\") {\n    $0.style = .dark\n}\n.onButtonClicked { _, buttonIndex in\n    print(\"Button Clicked At Index \\(buttonIndex)\")\n}\n```\n\nAdd text fields\n\n```swift\nSwiftAlertView.show(title: \"Sign in\", buttonTitles: \"Cancel\", \"Sign In\") { alertView in\n    alertView.addTextField { textField in\n        textField.placeholder = \"Username\"\n    }\n    alertView.addTextField { textField in\n        textField.placeholder = \"Password\"\n    }\n    alertView.isEnabledValidationLabel = true\n    alertView.isDismissOnActionButtonClicked = false\n}\n.onActionButtonClicked { alertView, buttonIndex in\n    let username = alert.textField(at: 0)?.text ?? \"\"\n    if username.isEmpty {\n        alertView.validationLabel.text = \"Username is incorrect\"\n    } else {\n        alertView.dismiss()\n    }\n}\n.onTextChanged { _, text, textFieldIndex in\n    if textFieldIndex == 0 {\n        print(\"Username text changed: \", text ?? \"\")\n    }\n}\n```\n\nYou can show alert with custom content view\n\n```swift\n// with xib file\nSwiftAlertView.show(nibName: \"CustomView\", buttonTitles: \"OK\")\n\n// with custom UIView\nSwiftAlertView.show(contentView: customView, buttonTitles: \"OK\")\n```\n\n### Programmatically creating an alert\n\nInitialize an alert\n\n```swift\nlet alertView = SwiftAlertView(title: \"Title\", message: \"Message\", buttonTitles: \"Cancel\", \"Button 1\", \"Button 2\", \"Button 3\")\n\nlet alertView = SwiftAlertView(contentView: customView, buttonTitles: \"OK\")\n\nlet alertView = SwiftAlertView(nibName: \"CustomView\", buttonTitles: \"OK\")\n```\n\nShow or dismiss\n\n```swift\n// Show at center of screen\nalertView.show()\n\n// Show at center of a view\nalertView.show(in: view)\n\n// Programmatically dismiss the alert view\nalertView.dismiss()\n```\n\nHandle button clicked event\n\n```swift\n\nalertView.onButtonClicked { _, buttonIndex in\n    print(\"Button Clicked At Index \\(buttonIndex)\")\n}\nalertView.onActionButtonClicked { _, buttonIndex in\n    print(\"Action Button Clicked At Index \\(buttonIndex)\")\n}\n```\n\nIf you don't want to use closures, make your view controller conform ```SwiftAlertViewDelegate``` and use delegate methods:\n\n```swift\nalertView.delegate = self\n\nfunc alertView(_ alertView: SwiftAlertView, clickedButtonAtIndex buttonIndex: Int) {\n    println(\"Button Clicked At Index \\(buttonIndex)\")\n}\n\nfunc didPresentAlertView(_ alertView: SwiftAlertView) {\n    println(\"Did Present Alert View\")\n}\n\nfunc didDismissAlertView(_ alertView: SwiftAlertView) {\n    println(\"Did Dismiss Alert View\")\n}\n```\n### Customization\n\nSwiftAlertView can be customized with the following properties:\n\n```swift\npublic var style: Style = .auto // default is based on system color\n\npublic var titleLabel: UILabel! // access titleLabel to customize the title font, color\npublic var messageLabel: UILabel! // access messageLabel to customize the message font, color\n\npublic var backgroundImage: UIImage?\n// public var backgroundColor: UIColor? // inherits from UIView\n\npublic var cancelButtonIndex = 0 // default is 0, set this property if you want to change the position of cancel button\npublic var buttonTitleColor = UIColor(red: 0, green: 0.478431, blue: 1, alpha: 1) // to change the title color of all buttons\npublic var buttonHeight: CGFloat = 44.0\n\npublic var separatorColor = UIColor(red: 196.0/255, green: 196.0/255, blue: 201.0/255, alpha: 1.0) // to change the separator color\npublic var isHideSeparator = false\npublic var cornerRadius: CGFloat = 12.0\n\npublic var isDismissOnActionButtonClicked = true // default is true, if you want the alert view will not be dismissed when clicking on action buttons, set this property to false\npublic var isHighlightOnButtonClicked = true\npublic var isDimBackgroundWhenShowing = true\npublic var isDismissOnOutsideTapped = false\npublic var dimAlpha: CGFloat = 0.4\npublic var dimBackgroundColor: UIColor? = .init(white: 0, alpha: 0.4)\n\npublic var appearTime = 0.2\npublic var disappearTime = 0.1\n\npublic var transitionType: TransitionType = .default\n\n// customize the margin \u0026 spacing of title \u0026 message\npublic var titleSideMargin: CGFloat = 20.0\npublic var messageSideMargin: CGFloat = 20.0\npublic var titleTopMargin: CGFloat = 20.0\npublic var messageBottomMargin: CGFloat = 20.0\npublic var titleToMessageSpacing: CGFloat = 20.0\n\n// customize text fields\npublic var textFieldHeight: CGFloat = 34.0\npublic var textFieldSideMargin: CGFloat = 15.0\npublic var textFieldBottomMargin: CGFloat = 15.0\npublic var textFieldSpacing: CGFloat = 10.0\npublic var isFocusTextFieldWhenShowing = true\npublic var isEnabledValidationLabel = false\npublic var validationLabel: UILabel! // access to validation label to customize font, color\npublic var validationLabelTopMargin: CGFloat = 8.0\npublic var validationLabelSideMargin: CGFloat = 15.0\n```\n\n## Contributing\nContributions for bug fixing or improvements are welcomed. Feel free to submit a pull request.\nIf you have any questions, feature suggestions or bug reports, please send me an email to dinhquan191@gmail.com.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdinhquan%2FSwiftAlertView","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdinhquan%2FSwiftAlertView","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdinhquan%2FSwiftAlertView/lists"}