views:

375

answers:

1

Does anyone know how to slide in a UIDatePicker with a Done button like the keyboard control? If so, can you share some sample code on how. Thanks

+1  A: 

I suggest you use a UIViewController, and show it modally.

Create UIViewController and setup the view with OK-button in Interface Builder, as you would for any view controller.

And display it using:

- (void)presentModalViewController:(UIViewController *)modalViewController 
                          animated:(BOOL)animated

You can set the root views background to clear if you want it transparent. And optionaly animate it to cemi-transparent black when the transition has finished. Something like this would work:

- (void)viewDidAppear:(BOOL)animated {
  if (animated) [UIView beginAnimations:@"fadeDark" context:NULL];
  self.view.backgroundColor = [UIColor colorWithWithe:0.0f alpha:0.5f];
  if (animated) [UIView commitAnimations];
}
PeyloW