PDA

View Full Version : Slide in and Out of View




forrestgrant
Aug 8, 2008, 01:51 PM
Hi,

I have a date picker, that just appears on screen:

UIDatePicker *datePickerView = [[UIDatePicker alloc] initWithFrame:CGRectZero];
datePickerView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
datePickerView.datePickerMode = UIDatePickerModeDate;

CGSize pickerSize = [datePickerView sizeThatFits:CGSizeZero];
datePickerView.frame = CGRectMake(0.0, 420, pickerSize.width, 460);
datePickerView.backgroundColor = [UIColor blackColor];

[myView addSubview:datePickerView];
This works great, but is there a way to have it animate up or slide up, like the keyboard does in Safari etc?

Thanks!



SwampThingTom
Aug 8, 2008, 02:04 PM
You can use UIView's beginAnimations:context method before adding the date picker as a subview and then use commitAnimations after adding it. The "Animating Views" section of the iPhone OS Programming Guide has more info:

http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/WindowsandViews/chapter_7_section_5.html#//apple_ref/doc/uid/TP40007072-CH8-SW11

Tom