自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

iPhone實(shí)例 底部出現(xiàn)時(shí)間選擇器

移動(dòng)開發(fā) iOS
本文介紹的是iPhone實(shí)例 底部出現(xiàn)時(shí)間選擇器,一個(gè)有趣的小實(shí)例,我們一起來看內(nèi)容。

iPhone實(shí)例 底部出現(xiàn)時(shí)間選擇器是本文要介紹的內(nèi)容,我們用iphone控件實(shí)現(xiàn)form表單時(shí),有時(shí)需要添加時(shí)間控件,一般的做法是添加按鈕,點(diǎn)擊按鈕從底部出現(xiàn)時(shí)間選擇器。如下圖:

iPhone實(shí)例 底部出現(xiàn)時(shí)間選擇器

實(shí)現(xiàn)代碼:

  1. #import "iphone_datapicketViewController.h"   
  2. @implementation iphone_datapicketViewController   
  3. @synthesize myDatePicker,myView;   
  4. - (void)viewDidLoad {   
  5.     [super viewDidLoad];   
  6. }   
  7. - (void)didReceiveMemoryWarning {   
  8.     [super didReceiveMemoryWarning];   
  9. }   
  10. - (void)viewDidUnload {   
  11.     self.myDatePicker =nil;   
  12.     self.myView=nil;   
  13. }   
  14. - (void)dealloc {   
  15.     [self.myDatePicker release];   
  16.     [self.myView release];   
  17.     [super dealloc];   
  18. }   
  19. -(IBAction)onClickButton:(id)sender   
  20. {   
  21.     [self showDatePick];   
  22. }   
  23. -(IBAction)onClickCloseButton:(id)sender   
  24. {   
  25.     [self dissDatePick];   
  26. }   
  27. -(void)showDatePick   
  28. {   
  29.     if (self.myView.superview == nil)   
  30.     {   
  31.         [self.view.window addSubview: self.myView];   
  32.     }      
  33.     CGRect screenRect = [[UIScreen mainScreen] applicationFrame];   
  34.     CGSize pickerSize = [self.myView sizeThatFits:CGSizeZero];   
  35.     CGRect startRect = CGRectMake(0.0,   
  36.                                   screenRect.origin.y + screenRect.size.height,   
  37.                                   pickerSize.width, pickerSize.height);   
  38.     self.myView.frame = startRect;   
  39.     CGRect pickerRect = CGRectMake(0.0,   
  40.                                    screenRect.origin.y + screenRect.size.height – pickerSize.height,   
  41.                                    pickerSize.width,   
  42.                                    pickerSize.height);   
  43.     [UIView beginAnimations:nil context:NULL];   
  44.     [UIView setAnimationDuration:0.3];   
  45.     [UIView setAnimationDelegate:self];   
  46.     self.myView.frame = pickerRect;   
  47.     CGRect newFrame = self.view.frame;   
  48.     newFrame.size.height -self.myView.frame.size.height;   
  49.     self.view.frame = newFrame;   
  50.     [UIView commitAnimations];   
  51. }   
  52. -(void)dissDatePick   
  53. {   
  54.     CGRect screenRect = [[UIScreen mainScreen] applicationFrame];   
  55.     CGRect endFrame = self.myView.frame;   
  56.     endFrame.origin.y = screenRect.origin.y + screenRect.size.height;   
  57.     [UIView beginAnimations:nil context:NULL];   
  58.     [UIView setAnimationDuration:0.3];   
  59.     [UIView setAnimationDelegate:self];   
  60.     self.myView.frame = endFrame;   
  61.     [UIView commitAnimations];   
  62.     CGRect newFrame = self.view.frame;   
  63.     newFrame.size.height += self.myView.frame.size.height;   
  64.     self.view.frame = newFrame;   
  65. }   
  66. @end 

還有利用ib創(chuàng)建控件和相連。

源代碼:http://easymorse-iphone.googlecode.com/svn/trunk/iphone.datapicket/

小結(jié):iPhone實(shí)例 底部出現(xiàn)時(shí)間選擇器的內(nèi)容介紹完了,希望本文對你有所幫助!

責(zé)任編輯:zhaolei 來源: 互聯(lián)網(wǎng)
相關(guān)推薦

2017-03-20 14:46:07

Android日期時(shí)間選擇器

2016-10-25 14:49:49

javascriptmaterial-uidatepicker

2012-04-16 14:32:31

iOS選擇器代碼

2021-08-14 06:49:44

谷歌Android UI

2011-11-28 13:42:55

Sencha Touc組件選擇器

2012-12-27 14:08:39

Android開發(fā)顏色選擇器

2010-09-03 09:30:29

CSS選擇器

2022-05-10 07:49:40

CSS選擇器

2010-09-07 11:14:32

CSS屬性選擇器CSS

2013-03-11 10:30:56

CSSWeb

2009-07-16 11:02:33

Swing文件選擇器

2023-03-16 10:20:55

CSS選擇器

2010-07-20 10:11:32

jQuery選擇器Sizzle

2010-08-26 12:47:15

CSSclass

2010-09-06 08:52:00

CSS選擇器

2010-12-27 16:01:45

jQuery選擇器

2023-01-30 08:42:33

CSS選擇器性能

2020-10-25 08:57:56

CSS前端瀏覽器

2012-06-12 09:43:11

jQuery

2011-10-24 10:30:20

CSS
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)