{"id":17335982,"url":"https://github.com/basthomas/imagealertaction","last_synced_at":"2026-03-04T11:32:18.826Z","repository":{"id":32699323,"uuid":"140344037","full_name":"BasThomas/ImageAlertAction","owner":"BasThomas","description":"Image support for UIAlertAction","archived":false,"fork":false,"pushed_at":"2023-03-17T05:45:13.000Z","size":228,"stargazers_count":34,"open_issues_count":3,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-11T11:04:17.586Z","etag":null,"topics":["image","swift","uialertaction","uialertcontroller","uiimage","uikit"],"latest_commit_sha":null,"homepage":null,"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/BasThomas.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-09T21:27:38.000Z","updated_at":"2021-12-17T04:51:07.000Z","dependencies_parsed_at":"2023-02-16T13:15:54.864Z","dependency_job_id":null,"html_url":"https://github.com/BasThomas/ImageAlertAction","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BasThomas%2FImageAlertAction","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BasThomas%2FImageAlertAction/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BasThomas%2FImageAlertAction/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BasThomas%2FImageAlertAction/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BasThomas","download_url":"https://codeload.github.com/BasThomas/ImageAlertAction/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219843493,"owners_count":16556506,"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":["image","swift","uialertaction","uialertcontroller","uiimage","uikit"],"created_at":"2024-10-15T15:27:03.058Z","updated_at":"2026-03-04T11:32:18.748Z","avatar_url":"https://github.com/BasThomas.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Travis status](https://img.shields.io/travis/BasThomas/ImageAlertAction.svg)](https://travis-ci.org/BasThomas/ImageAlertAction)\n\n# ImageAlertAction\n\n`ImageAlertAction` is a `UIAlertAction` extension that adds support for an image\nin the action's button.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"assets/actionsheet.png\" alt=\"Action Sheet\" width=\"300\"\u003e \u003cimg src=\"assets/alert.png\" alt=\"Alert\" width=\"300\"\u003e\n\u003c/p\u003e\n\n## Example\n\nTo run the example project, clone the repository, and run `pod install` from the Example\ndirectory first.\n\n## Installation\n\nImageAlertAction is available through [CocoaPods](https://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod 'ImageAlertAction'\n```\n\n## Usage\n\n### Adding an image to a `UIAlertAction`\n\nCreate a `UIAlertAction` like you'd do normally, and pass an image to the `image` parameter.\nThis will add the image on the left of the action's button.\n\n```swift\nlet settings = UIAlertAction(\n  title: \"Settings\",\n  image: #imageLiteral(resourceName: \"settings\"),\n  style: .default\n)\n```\n\n#### Keeping the `UIImage`'s original color\n\nBy default, the image provided will be treated as a template, and will be recolored based on the\naction's `style`. If you want to draw the original image, you can pass an image with an\nexplicit rendering mode.\n\n```swift\nlet settingsImage = #imageLiteral(resourceName: \"settings\").withRenderingMode(.alwaysOriginal) \nlet settings = UIAlertAction(\n  title: \"Settings\",\n  image: settingsImage,\n  style: .default\n)\n```\n\n#### Accessing the added `UIImage`\n\nAs with the title and style, you can access the image set on the `UIAlertAction`.\n\n```swift\nlet settings = UIAlertAction(\n  title: \"Settings\",\n  image: #imageLiteral(resourceName: \"settings\"),\n  style: .default\n)\nsettings.image // returns an optional UIImage\n```\n\n#### Adding a checkmark\n\nYou can also show a check mark on actions via `isChecked`.\n\n```swift\nlet settings = UIAlertAction(\n  title: \"Settings\",\n  image: #imageLiteral(resourceName: \"settings\"),\n  isChecked: true\n  style: .default\n)\nsettings.isChecked // returns a Bool\n```\n\n### Presenting the `UIAlertController`\n\nTo present a `UIAlertController` containing the `UIAlertAction`, nothing changes.\n\n```swift\nlet alertController = UIAlertController(\n  title: \"Title\",\n  message: \"Message\",\n  preferredStyle: .actionSheet\n)\n\nlet settings = UIAlertAction(\n  title: \"Settings\",\n  image: #imageLiteral(resourceName: \"settings\"),\n  style: .default\n)\nalertController.addAction(settings)\n\npresent(alertController, animated: true)\n```\n\n## Acknowledgements\n\n- Created by [Bas Broek](https://twitter.com/basthomas)\n\n## License\n\nImageAlertAction is available under the MIT license. See the [LICENSE](LICENSE) file for more\ninfo.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasthomas%2Fimagealertaction","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbasthomas%2Fimagealertaction","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasthomas%2Fimagealertaction/lists"}