2012-03-07 27 views
-2

如何動作像動作表一樣的自定義選取器視圖?像動作表一樣的自定義選取器視圖動畫

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

最新的問題!? – calimarkus 2012-03-07 21:14:55

+0

我有一個自定義視圖與按鈕比選取器視圖我怎麼可以顯示它從底部滑動 – user1120133 2012-03-07 21:16:02

回答

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]; 
} 
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位置)爲視圖的垂直位置設置動畫。

+0

這需要uiview和按鈕向下我只是想自定義視圖以滑動的方式從底部彈出。我不想將自定義視圖置於頂部。 – user1120133 2012-03-07 21:29:54

+0

是不是你的按鈕的視圖子視圖?他們應該是。但你只需要修復你的座標。嘗試'[查看setFrame:CGRectMake(0,160,320,300)];' – calimarkus 2012-03-07 21:34:17

相關問題