如何为动作表等自定义选择器视图设置动画?
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];
答案 0 :(得分:0)
就像你做的那样:
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。它的(x,y,width,height)
。因此,您必须使用第二个参数(y位置)为视图的垂直位置设置动画。
答案 1 :(得分:0)
对于自定义选择器视图,这是正确答案,但它不会像操作表那样动画。但它会创建自定义选择器视图。
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];
}