我想使用动画从窗口底部加载视图,我知道这可以通过 presentmodalViewController 完成,但根据我的应用程序的要求,它无效,因为我只想在窗口的一半加载视图。所以我使用了动画,看看我做了什么
-(void) displayPicker
{
UIButton *done = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[done setFrame:CGRectMake(197, 199, 103, 37)];
[done setBackgroundImage:[UIImage imageNamed:@"button_0.png"] forState:UIControlStateNormal];
[done setTitle:@"Done" forState:UIControlStateNormal];
[done setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[done addTarget:self action:@selector(dismissView) forControlEvents:UIControlEventTouchUpInside];
[pickerDisplayView addSubview:datePicker];
[pickerDisplayView addSubview:done];
//animating here
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
pickerDisplayView = [[UIView alloc]initWithFrame:CGRectMake(0, 185, 320, 275)];
[self.view addSubview:pickerDisplayView];
[UIView commitAnimations];
}
名为 pickerDisplayView 的视图有两个名为 Picker 和 Button 的组件,但问题是 Picker 无法正常工作,并且视图 (pickerDisplayView) 都无法顺利加载。
@Matt:我按照你的指示做了,按照你的建议做了
-(void) animationIn
{
CGPoint p = {x:0,y:185};
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
//pickerDisplayView = [[UIView alloc]initWithFrame:CGRectMake(0, 185, 320, 275)];
[pickerDisplayView setCenter:p];
[UIView commitAnimations];
}
但问题是视图在窗口顶部,而不是在 185 的确切 y 轴上。我从 IB 获取了这些坐标。请帮帮我先生