如何在按下背景时动画隐藏选取器视图

时间:2013-03-24 09:47:23

标签: ios objective-c uipickerview

如何在点击背景时动画隐藏选择器视图?试过这个:

[self.picker setHidden:YES];

但是选择器突然消失了。我想让它在屏幕外向下动画。 注意:我知道如何实现点击背景以消除部分帖子,所以请忽略它。

3 个答案:

答案 0 :(得分:3)

[UIView animateWithDuration:0.3 animations:^{
    self.picker.center = CGPointMake(self.picker.center.x, self.picker.center.y + self.picker.frame.size.height);
} completion:^(BOOL finished){
    self.picker.hidden = YES;
}];

这会将拾取器滑到底部,然后在动画结束时隐藏它。

答案 1 :(得分:1)

[UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.3f]; // you can set value as per you need.
    [self.picker setHidden:YES];
    [UIView commitAnimations];

答案 2 :(得分:1)

[UIView animateWithDuration:0.3 animations:^{
     self.picker.frame = CGRectMake(self.picker.frame.origin.x,self.picker.frame.origin.y+self.picker.frame.size.height,self.picker.frame.size.width,self.picker.frame.size.height);
}completion:^(BOOL fin) {

}];