The time control, whether Android or iOS, is a control that is bound to exist, with the exact same effect, showing the date, time, and four ways in which iOS can be selected, when, date,date and times, Count down Timer,demo is easier, You need a DatePicker control and a button to display the time or date, as follows:
Page Layout
Main.storyboard layout:
Y
Effect:
Code implementation
First drag the control into ViewController.h and drag the button's click into the VIEWCONTROLLER.M:
-(Ibaction) Showdate: (ID) Sender { //Date selection time nsdate *currentdate = [_currentdatepicker date]; NSDateFormatter *myformatter = [[NSDateFormatter alloc] init]; Date format displayed// [MyFormatter setdateformat:@ "Yy-mm-dd HH:mm:ss"]; [MyFormatter setdateformat:@ "yyyy mm month DD Day"]; NSString *time = [MyFormatter stringfromdate:currentdate]; Uialertview *alterview=[[uialertview alloc] initwithtitle:@ "Current Time" Message:time delegate:self cancelButtonTitle:@ "OK" Otherbuttontitles:nil, nil]; [Alterview show];}
The final effect is as follows:
DatePicker mode I choose is the time pattern, we can choose according to their own choice, the default is displayed in English, if DatePicker need to switch between English and Chinese, you can choose the locale to choose English:
iOS Development-datepicker Controls