当我调出选择器时,我想为背景设置动画并慢慢变暗。然后当我把它放下时,我想慢慢地把它动画化。出于某种原因,它只在我打开 pickerView 时起作用,而不是在想要将其关闭时起作用。
此代码有效:
-(IBAction)chooseCategory:(id)sender{
[self.chooseCategoryView setHidden:NO];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.4];
self.categoryPicker.frame = CGRectMake(0, 151, 320, 367);
self.categoryPickerToolbar.frame = CGRectMake(0, 106, 320, 45);
self.pickerViewBackground.alpha = 0.6;
[UIView commitAnimations];
[self.scrollView setUserInteractionEnabled:NO];
}
但这并不
-(IBAction)hideCategory:(id)sender {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.4];
self.pickerViewBackground.alpha = 0;
self.categoryPicker.frame = CGRectMake(0, 545, 320, 367);
self.categoryPickerToolbar.frame = CGRectMake(0, 500, 320, 367);
[UIView commitAnimations];
[self.chooseCategoryView setHidden:YES];
[self.scrollView setUserInteractionEnabled:YES];
}
有谁知道为什么不呢?