Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save amratab/df82c69baa10fcb6170e5600bc278ff5 to your computer and use it in GitHub Desktop.
Save amratab/df82c69baa10fcb6170e5600bc278ff5 to your computer and use it in GitHub Desktop.
adding custom buttons etc to alerts
@IBAction func showAlertButtonTapped(sender: UIButton) {
// create the alert
let alertController = UIAlertController(title: "Add Card", message: "Add your card details here and hit save\n\n\n", preferredStyle: UIAlertControllerStyle.Alert)
// alertController.view.frame = CGRectMake(0, 0, self.view.bounds.size.width-20, 400)
// let margin:CGFloat = 8.0
// let rect = CGRectMake(margin, margin, alertController.view.bounds.size.width - margin * 4.0, 44)
// let customView = UIView(frame: rect)
paymentTextField.frame = CGRectMake(5, 75, alertController.view.bounds.size.width - 150, 44)//
alertController.view.addSubview(paymentTextField)
let cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel, handler: {(alert: UIAlertAction!) in print("cancel")})
alertController.addAction(saveAction)
alertController.addAction(cancelAction)
self.presentViewController(alertController, animated: true, completion:{}) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment