Countdown @implementation viewcontroller- (void) viewdidload { [super viewdidload]; [nstimer scheduledtimerwithtimeinterval:1.0f target:self Selector: @selector (Jishi) userinfo:nil repeats:yes];} - (void) didreceivememorywarning { [super didreceivememorywarning];} -(void) jishi{ //converted to local time nsdate *begindate = [[ Nsdate alloc]init]; nsstring *[email protected] "2015-11-14 00:00:00 +00 "; nsdateformatter *format = [[nsdateformatter alloc]init] ; [format setdateformat:@ "Yyyy-mm-dd hh:mm:ss +hh"]; NSDate *endDate = [format dateFromString:endtime]; nsstring *beg=[format stringfromdate:begindate]; nslog (@ "%@,%@", beg,enddate); _ Begin.text=beg; nsmutablestring *string = [[nsmutablestring alloc] init]; nstimeinterval timedif = [enddate Timeintervalsince1970]-[begindate timeintervalsince1970]; int shi= timeDif/3600; int fen= (timedif-(shi*60*60))/60; int miao=timedif-(shi*60*60)-(fen*60); [string appendstring:[ nsstring stringwithformat:@ "%i-%i-%i", Shi,fen,miao]];// nslog (@ "%@", String); _countDown.text=string;// _countDown.text=string; _end.text=[nsstring stringwithformat:@ "%@", [format stringfromdate: Enddate]]; }//uiimage- (void) viewdidload { [super viewdidload]; _i= 20; //Picture Instantiation method One: uiimageview * imageview = [ [ UIImageView alloc ] init ] ; //Picture Instantiation Method Two: uiimageview * imageviewi = [ [ UIImageView alloc ] initWithFrame: CGRectMake ( 10, 10, 200, 200 ) ] ; //Set the content of ImageView imageviewi.image = [ uiimage imagenamed:@ "0" ] ; //Picture Instantiation Method Three: uiimageview * imageviewii = [ [ uiimageview alloc ] initwithimage : [ uiimage imagenamed : @ "4" ] ] ; //setting the size of the ImageView imageViewII.frame = CGRectMake ( 180, 100, 100, 100 ) ; //image instantiation Method Four: (Picture two States) _imageViewIII = [ [ UIImageView alloc ] initwithimage : [ uiimage imagenamed:@ "1" ] highlightedImage : [ uiimage imagenamed:@ "2" ] ] ; _imageViewIII.frame = cgrectmake ( 5,5, 100, 100 ) ; //add a picture to the page [ self.view addsubview:_ imageviewiii ] ; //Add button to control picture status uibutton * button = [ [ uibutton alloc ] initwithframe : cgrectmake ( 80, 80, 180, 30 ) ] ; [ button settitle : @ "Highlight Toggle" forState : UIControlStateNormal ] ; button.backgroundcolor = [ uicolor redcolor ] ; [ button addtarget : self action : @selector (Gaoliang) forControlEvents :uicontroleventtouchupinside]; [self.view addsubview:button]; // ========= gestures on pictures ======== _imageviewiiii = [ [ uiimageview alloc ] initwithimage : [ uiimage imagenamed:@ "4" ] ]; _imageviewiiii.frame = cgrectmake (10, 150, 100, 100); _imageviewiiii.backgroundcolor=[uicolor redcolor];//can add a background color to the image to clarify the difference between image and ImageView //add a picture to the page [self.view addsubview: _imageviewiiii]; //Images Support Interactive _ imageviewiiii.userinteractionenabled = yes; // Defining gestures uitapgesturerecognizer *gestur = [ [ uitapgesturerecognizer alloc ]initwithtarget:self action: @selector (Shoushi) ]; // Add a picture gesture [_imageViewIIII addGestureRecognizer:gestur]; // =========== Picture Rotation ============ _rotationimageview = [[ uiimageview alloc]initwithimage:[ uiimage imagenamed:@ "0"  ] ] ; _rotationimageview.frame=cgrectmake (200, 200, 100, 100); [self.view addSubview:_rotationImageView]; //Add button control Picture status UIButton * buttonI = [ [ uibutton alloc ] initwithframe : cgrectmake ( 200, 150, 80, 30 ) ] ; [ buttoni settitle : @ "Picture Rotation" forState : uicontrolstatenormal ] ; buttoni.backgroundcolor = [ uicolor redcolor ] ; [ buttoni addtarget : self action : @selector (Xuanzhuan) forControlEvents:UIControlEventTouchUpInside]; [self.view addsubview:buttoni]; // =========== Picture Indent ============ _changesizeimageview = [[ uiimageview alloc]initwithimage:[ uiimage imagenamed:@ "2" ] ] ; _changesizeimageview.frame=cgrectmake (20, 300, 100, 100); [self.view addsubview:_changesizeimageview]; // Add button control picture magnification uibutton * buttonbig = [ [ uibutton alloc ] initWithFrame : CGRectMake ( 110, 320, 80, 30 ) ] ; [ buttonbig settitle : @ "Picture amplification"  FORSTATE : UIControlStateNormal ] ; buttonBig.backgroundColor = [ UICOLOR REDCOLOR ] ; [ buttonBig addTarget : self action : @selector (Fangda) forControlEvents:UIControlEventTouchUpInside]; [self.view addsubview:buttonbig]; //Add button control picture reduction UIButton * Buttonsmall = [ [ uibutton alloc ] initwithframe : cgrectmake ( 110, 360, 80, 30 ) ] ; [ buttonsmall settitle : @ "Picture Zoom Out" forState : UIControlStateNormal ] ; buttonSmall.backgroundColor = [ UIColor redColor ] ; [ buttonSmall addTarget : self action : @selector (Suoxiao ) forcontrolevents:uicontroleventtouchupinside]; [self.view addsubview: buttonsmall]; //====== using Frame Control zoom ====== _changeFrameImageView = [[ UIImageView alloc]initWithImage:[ uiimage imagenamed:@ "5" ] ] ; _changeframeimageview.frame= CGRectMake (120, 430, 100, 100); [self.view addsubview:_ changeframeimageview]; //Add button control image magnification Uibutton * framebig = [ [ uibutton alloc ] initwithframe : CGRectMake ( 110, 600, 50, 30 ) ] ; [ framebig settitle : @ "Enlarge"  FORSTATE : UICONTROLSTATENORMAL ] ; frameBig.backgroundColor = [ UIColor redColor ] ; [ framebig addtarget : self action : @selector (Zengda) forcontrolevents: uicontroleventtouchupinside]; [self.view addsubview:framebig]; //Add button control picture reduction UIButton * frameSmall = [ [ uibutton alloc ] initwithframe : cgrectmake ( 220, 600,50, 30 ) ] ; [ framesmall settitle : @ "Zoom Out" forState : UIControlStateNormal ] ; frameSmall.backgroundColor = [ uicolor redcolor ] ; [ framesmall addtarget : self action : @selector (Bianxiao) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:frameSmall]; // _imageviewiii.center=cgpointzero;//Set Picture Center location, Cgpointzero is the origin (0,0)// [self.view bringsubviewtofront:imageviewi];//move the control to the front // _imageViewIIII.contentMode=UIViewContentModeCenter;// _imageviewiii.transform=cgaffinetransformmaketranslation (100, 200);} //Add button control picture magnification callback method-(void) fangda{ _changesizeimageview.transform= Cgaffinetransformmakescale (2, 5);} //Add button control Picture Shrink callback Method-(void) suoxiao{ _changesizeimageview.transform= Cgaffinetransformmakescale (0.2, 0.5);} Image magnification callback Method-(void) zengda{ cgrect bonus = _changeframeimageview.bounds;// Image Center for Midpoint bonus.size.width += 30; bonus.size.height += 30; _changeframeimageview.bounds = bonus;} Picture reduction callback Method-(void) bianxiao{ cgrect frame = _ changeframeimageview.frame;//The top left corner of the picture is the center frame.size.height -= 30; frame.size.width -= 30; _changeframeimageview.frame = frame;} method to toggle highlighting added-(void) gaoliang{ if (_imageviewiii.highlighted==yes) { _imageViewIII.highlighted=NO; }else{ _imageviewiii.highlighted=yes; }}-(void) Shoushi{ nslog (@ "picture gesture method ... ");} Click on the image Rotation button to invoke the custom method, where you set the picture to rotate how much-(void) xuanzhuan{ _i+=20; _ Rotationimageview.transform=cgaffinetransformmakerotation (m_pi*_i/180);// This rotation is centered on the center of the image, the rotation angle is: m_pi*? In the/180? Position}- (void) didreceivememorywarning { [super didreceivememorywarning]; // dispose of any resources that can&nbsP;be recreated.} @end//datepicker (void) viewdidload { [super viewdidload]; // UIDatePicker is a controller class that is a subclass of Uicontrol that is dedicated to accepting input for date, time, and duration. The columns of the date picker are automatically configured according to the style you specify // UIDatePicker depend on NSDate class _datePicker.minuteInterval=6; //setting the style of the DatePicker _datepicker.datepickermode=uidatepickermodedate;// format A string of time as NSDate type nsstring *[email protected] " 2012-12-22 "; nsdateformatter *formatter=[[nsdateformatter alloc]init]; [formatter setdateformat:@ "Yyyy-mm-dd"]; nsdate *date=[ formatter datefromstring:string];// minimum time to set DatePicker _ Datepicker.minimumdate=date; //adding events to DatePicker [_datepicker addtarget:self action: @selector (datechange:) forControlEvents:UIControlEventValueChanged]; }//custom method of callback when DatePicker value changes-(void) Datechange: (uidatepicker *) sender{ nsdate *date=_datepicker.date; nslog (@ "%@", date);} - (void) didreceivememorywarning { [super didreceivememorywarning]; // dispose of any resources that can be recreated.} nsdate // insert code here... nslog (@ "hello, world!"); //how to get the current time there are two Nsdate * date = [ [ nsdate alloc ] init ] ; nsdate * dateI = [ NSDate date ] ;// Convert NSDate to nsstring nsdateformatter * dateformatter = [ [ nsdateformatter alloc ]init ] ; [ dateformatter setdateformat : @ "Yyyy-MM-dd HH:mm:ss"  ] ; nsstring * nowtime = [ [ NSString alloc ] init ] ; nowtime = [ dateformatter stringfromdate:datei ] ; NSLog (&Nbsp;@ " ==== %@ " , nowTime ); NSLog ( @ " %@ ---- %@ "   date , dateI ) ;// convert string to date nsstring * string = @ "2013-12-25 12:23:57 " ; nsdate * dateiii = [ dateFormatter dateFromString:string ] ; nslog ( @ "%@" , dateIII ) ; } return 0;}
[Extraordinary programmer] Countdown uiimage uidatepicker nsdate