I want to animate my UIPickerView after pressing the button. I already have coded my UIPickerView to be hidden on viewDidLoad and not hidden after pressing a button, but it does
You can use below function to perform animation of picker view.
-(void)hideShowPickerView {
if (!isPickerDisplay) {
[UIView animateWithDuration:0.25 animations:^{
CGRect temp = self.categoryPicker.frame;
temp.origin.y = self.view.frame.size.height - self.categoryPicker.frame.size.height;
self.categoryPicker.frame = temp;
} completion:^(BOOL finished) {
NSLog(@"picker displayed");
isPickerDisplay = YES;
}];
}else {
[UIView animateWithDuration:0.25 animations:^{
CGRect temp = self.categoryPicker.frame;
temp.origin.y = self.view.frame.size.height;
self.categoryPicker.frame = temp;
} completion:^(BOOL finished) {
NSLog(@"picker hide");
isPickerDisplay = NO;
}];
}
}
Define isPickerDisplay as BOOL and initialize this in to ViewDidLoad as given below -
isPickerDisplay = YES;
[self hideShowPickerView];
This will manage hide and show functionality for UIPickerView.