https://github.com/illescasdaniel/customizablealertcontroller
Hacking the UIAlertController to fully customize it
https://github.com/illescasdaniel/customizablealertcontroller
hacking ios swift uialertcontroller
Last synced: 4 months ago
JSON representation
Hacking the UIAlertController to fully customize it
- Host: GitHub
- URL: https://github.com/illescasdaniel/customizablealertcontroller
- Owner: illescasDaniel
- License: mit
- Created: 2018-01-07T19:15:25.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-10-29T08:27:49.000Z (about 7 years ago)
- Last Synced: 2025-07-03T18:11:10.792Z (6 months ago)
- Topics: hacking, ios, swift, uialertcontroller
- Language: Swift
- Size: 961 KB
- Stars: 32
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CustomizableAlertController
Hacking the UIAlertController to fully customize it!
## Screenshot

## Example
```swift
let customAlertController = CustomizableAlertController(title: "Do you want to do X?", message: ":D hii", preferredStyle: .alert)
customAlertController.addAction(title: "Yes", style: .default, image: X)
customAlertController.addAction(title: "Cancel", style: .cancel)
let greenAction = UIAlertAction(title: "I'm green!", style: .default)
customAlertController.addAction(greenAction)
let labelElement = UILabel(frame: CGRect(x: 0, y: 0, width: 50, height: 20))
labelElement.text = "Hii!!"
labelElement.textColor = .white
greenAction.accessoryView = labelElement
customAlertController.addParallaxEffect(x: 20, y: 20)
self.present(customAlertController, animated: true)
// customAlertController.lazyContentView?.backgroundColor = .red
customAlertController.titleAttributes += [
StringAttribute(key: .font, value: UIFont.boldSystemFont(ofSize: 17), range: NSRange(location: "Do ".count, length: "you".count)),
StringAttribute(key: .font, value: UIFont.boldSystemFont(ofSize: 17), range: NSRange(location: "Do you want to do ".count, length: "X".count))
]
customAlertController.messageAttributes += [
StringAttribute(key: .foregroundColor, value: UIColor.orange, range: NSRange(location: 0, length: 3))
]
greenAction.titleAttributes = [
StringAttribute(key: .foregroundColor, value: UIColor.green)
]
```
### Medium article
https://medium.com/@Daniel_illescas/hacking-ios-alerts-with-swift-61aefce9736a