Skip to main content

Posts

Showing posts with the label alertcontroller

Create AlertController in swift 3

let alertVC: UIAlertController = UIAlertController (title: "Alert" , message: "YOUR MESSAGE" , preferredStyle: .alert)   let okBtn = UIAlertAction. init (title: "Ok" , style: . default , handler: { _ in                           // Perform whatever you want                         })     alertVC.addAction(okBtn)     self .present(alertVC, animated: true , completion: nil )

Custom dropdown alert.

//Create a view to hold the label and add images or whatever, place it off screen at -100     UIView *alertview = [[ UIView alloc ] initWithFrame : CGRectMake ( 0 , - 100 , CGRectGetWidth ( self . view . bounds ), 100 )];     alertview. backgroundColor =[ UIColor redColor ];     //Create a label to display the message and add it to the alertView     UILabel *theMessage = [[ UILabel alloc ] initWithFrame : CGRectMake ( 0 , 0 , CGRectGetWidth (alertview. bounds ), CGRectGetHeight (alertview. bounds ))];          theMessage. text = @"Hey Alert showing" ;     [alertview addSubview :theMessage];     //Add the alertView to your view     [ self . view addSubview :alertview];     //Create the ending frame or where you want it to end up on screen, in this case 0 y origin     CGRect newFrm = alertview. frame ;     newFrm. origin . y = 0 ; ...