Subclass of UIAlertController
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
CustomAlertController.xcodeproj
CustomAlertController
README.md

README.md

CustomAlertController

Subclass of UIAlertController

Development Environmental

  • Xcode 9.1
  • Swift 4

System Requirements

  • iOS 10, 11

ActionSheet

actionsheet

@IBAction func actionSheetButtonTouched(_ sender: UIBarButtonItem) {
    let alert = CustomAlertController(title: "Very cute", message: "Animal, Pet, Cat", preferredStyle: .actionSheet)
    
    let storyboard = UIStoryboard(name: String(describing: CustomAlertSubtitleViewController.self), bundle: nil)
    let vc = storyboard.instantiateInitialViewController() as! CustomAlertSubtitleViewController
    vc.image = UIImage(named: "Cat")
    vc.text = alert.title
    vc.detailText = alert.message
    
    alert.contentViewController = vc
    alert.checkedIndex = 1
    
    alert.popoverPresentationController?.barButtonItem = sender
    
    alert.addAction(UIAlertAction(title: "SNS", style: .default) { (action: UIAlertAction) in
    })
    alert.addAction(UIAlertAction(title: "Mail", style: .default) { (action: UIAlertAction) in
    })
    alert.addAction(UIAlertAction(title: "Download", style: .default) { (action: UIAlertAction) in
    })
    alert.addAction(UIAlertAction(title: "Cancel", style: .cancel) { (action: UIAlertAction) in
    })
    present(alert, animated: true, completion: nil)
}

Alert

alert

@IBAction func alertButtonTouched(_ sender: UIBarButtonItem) {
    let alert = CustomAlertController(title: "Very cute", message: "Animal, Pet, Cat", preferredStyle: .alert)
    
    let storyboard = UIStoryboard(name: String(describing: CustomAlertSubtitleViewController.self), bundle: nil)
    let vc = storyboard.instantiateInitialViewController() as! CustomAlertSubtitleViewController
    vc.image = UIImage(named: "Cat")
    vc.text = alert.title
    vc.detailText = alert.message
    
    alert.contentViewController = vc
    alert.checkedIndex = 1
    
    alert.addTextField() { (text: UITextField) in
    }
    alert.addAction(UIAlertAction(title: "SNS", style: .default) { (action: UIAlertAction) in
    })
    alert.addAction(UIAlertAction(title: "Mail", style: .default) { (action: UIAlertAction) in
    })
    alert.addAction(UIAlertAction(title: "Download", style: .default) { (action: UIAlertAction) in
    })
    alert.addAction(UIAlertAction(title: "Cancel", style: .cancel) { (action: UIAlertAction) in
    })
    present(alert, animated: true, completion: nil)
}