自定义选取器视图类似于动作表的动画



如何设置自定义选择器视图(如actionsheet)的动画?

UIView *view = [[[UIView alloc]initWithFrame:CGRectMake(0,300,320,300)] autorelease];
view.backgroundColor = [UIColor brownColor];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:[self view] cache:YES];
[view setFrame:CGRectMake(0.0f,300.0f,320.0f,325.0f)];
[UIView commitAnimations]; 

就像你做的那样:

UIView *view=[[[UIView alloc]initWithFrame:CGRectMake(0,460,320,300)]autorelease];
view.backgroundColor=[UIColor brownColor];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:[self view] cache:YES];
[view setFrame:CGRectMake(0,0,320,300)];
[UIView commitAnimations]; 

但是看看CGRect。其CCD_ 1。因此,您必须使用第二个参数(y位置)来设置视图垂直位置的动画。

对于自定义选取器视图,正确答案是这样的,但它不会像动作表那样动画化。但它创建了自定义选取器视图。

items =[[NSArray alloc]initWithObjects:@"Hindi",@"English",nil];
pickerView=[[UIPickerView alloc] initWithFrame:CGRectMake(10,250,350,350)];
pickerView.transform = CGAffineTransformMakeScale(0.75f, 0.75f);
pickerView.delegate = self;
pickerView.dataSource = self;
pickerView.showsSelectionIndicator = YES;
pickerView.backgroundColor = [UIColor clearColor];
[pickerView selectRow:1 inComponent:0 animated:YES];
[self.view addSubview:view]; 

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView;
{
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component;
{
return [items count];   
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
return[items objectAtIndex:row];
}

最新更新