有人知道如何像键盘一样在UIDatePicker中滑动吗?

问题描述 投票:0回答:2

有没有人知道如何使用键盘控件等完成按钮在UIDatePicker中滑动?如果是这样,你可以分享一些示例代码。谢谢

objective-c iphone animation uidatepicker
2个回答
1
投票

我建议你使用UIViewController,并以模态显示它。

创建UIViewController并使用Interface Builder中的OK按钮设置视图,就像对任何视图控制器一样。

并使用以下方式显示:

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

如果希望透明,可以将根视图背景设置为清除。并且当转换完成时,可选地将其设置为透明黑色。像这样的东西会起作用:

- (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];
}

0
投票

1.创建UIButton类的子类

2.redeclare inputview为读写

@property (nonatomic, strong, readwrite) UIView *inputView;

3.set canBecomeFirstResponder为YES

- (BOOL)canBecomeFirstResponder {
return YES;
}

4.将inputview设置为datepicker

self.inputView = self.datePicker;

5.如果需要,将UIResponder设置为firstResponder

[self becomeFirstResponder];

你可以在键盘上看到日期选择器幻灯片

© www.soinside.com 2019 - 2024. All rights reserved.