Here is the code to create the UIAlertController to display the message and the header.
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Alert Controller" message:@"Alert Message" preferredStyle:UIAlertControllerStyleAlert]; UIViewController *viewController = [[UIViewController alloc]init]; [viewController.view setBackgroundColor:[UIColor blueColor]]; UILabel *lbl = [[UILabel alloc]initWithFrame:CGRectMake(10, 8, 250, 30)]; lbl.text = @"This is a label"; lbl.textAlignment = NSTextAlignmentCenter; lbl.textColor = [UIColor whiteColor]; [viewController.view addSubview:lbl]; UITextField *tf = [[UITextField alloc]initWithFrame:CGRectMake(10, 35, 250, 30)]; tf.borderStyle = UITextBorderStyleRoundedRect; tf.placeholder = @"Enter your name"; [viewController.view addSubview:tf]; [alertController setValue:viewController forKey:@"contentViewController"]; UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { NSLog(@"Cancel action"); }]; UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { NSLog(@"OK action"); NSLog(@"Text Value : %@",tf.text); }]; [alertController addAction:cancelAction]; [alertController addAction:okAction]; dispatch_async(dispatch_get_main_queue(), ^{ [self presentViewController:alertController animated:YES completion:nil]; });

For quick, you can do the same as the following code:
let alert = UIAlertController(title: "Alert Controller", message: "Alert Message", preferredStyle: UIAlertControllerStyle.Alert) let cancelAction = UIAlertAction( title: "Cancel", style: UIAlertActionStyle.Destructive) { (action) in } let confirmAction = UIAlertAction( title: "OK", style: UIAlertActionStyle.Default) { (action) in } alert.addAction(confirmAction) alert.addAction(cancelAction) let VC = UIViewController() VC.view.backgroundColor = UIColor.blackColor() let lbl = UILabel() lbl.frame = CGRectMake(10, 8, 250, 30) lbl.text = "this is a label" lbl.textAlignment = NSTextAlignment.Center lbl.textColor = UIColor.whiteColor() VC.view .addSubview(lbl) let txt = UITextField() txt.frame = CGRectMake(10, 35, 250, 30) txt.borderStyle = UITextBorderStyle.RoundedRect txt.placeholder = "enter text" VC.view .addSubview(txt) alert.setValue(VC, forKey: "contentViewController") self.presentViewController(alert, animated: true, completion: nil)

Download demo from Github: https://github.com/nitingohel/NGAlertViewController-Swift2.0
source share