[:en]Swift: Date Picker[:]

[:en]DatePicker

DatePicker2


import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var myDatePicker: UIDatePicker!
   
      @IBOutlet weak var dateLabel: UIButton!
 
    
    override func viewDidLoad() {
        super.viewDidLoad()
         myDatePicker.hidden = true
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    @IBAction func showDatePicker(sender: AnyObject) {
        myDatePicker.hidden = false
        
    }
   
    @IBAction func datePickerAction(sender: AnyObject) {
        
        let dateFormatter = NSDateFormatter()
        dateFormatter.dateFormat = "dd-MM-yyyy HH:mm"
        let Dateset = dateFormatter.stringFromDate(myDatePicker.date)
        dateLabel.setTitle(Dateset, forState: .Normal)
    }
}


Here is the source code:

DatePick[:]

Print Friendly, PDF & Email
Scroll to Top