我想从上到下创建UIView
动画方向,但是在我尝试了两天之后,我就已经投降了
这是我的代码
- (IBAction)goAction:(id)sender
{
primaryView.userInteractionEnabled = NO;
[UIView animateWithDuration:0.3 animations:^{
secondaryView.frame = CGRectMake(0, 100, secondaryView.frame.size.width, secondaryView.frame.size.height);
CALayer *layer = primaryView.layer;
layer.zPosition = -4000;
CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity;
rotationAndPerspectiveTransform.m21 = 1.0 / -300;
layer.transform = CATransform3DRotate(rotationAndPerspectiveTransform, 10.0f * M_PI / 180.0f, 1.0f, 0.0f, 0.0f);
primaryShadeView.alpha = 0.35;
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.3 animations:^{
primaryView.transform = CGAffineTransformMakeScale(0.9,0.9);
primaryShadeView.alpha = 0.5;
}];
}];
}
这个方向......自下而上......希望你们都能帮助我:)。
答案 0 :(得分:1)
最初将视图分配到一个位置,使其落在导航栏上方。
CGRectMake(0, 100, secondaryView.frame.size.width, secondaryView.frame.size.height);
此处将值100更改为足以隐藏已分配视图的负值。在使用动画显示时,使用相同的CGRectMake参数,仅更改“y”,给出位置以在屏幕上显示。在nNext上单击以相同方式隐藏它。
这有意义吗?
以下是样本:
在您的按钮操作中:
{
if(!youNewView)
{
youNewView = [[UIView alloc] initWithFrame:CGRectMake(self.view.frame.size.width, -220(depends on your view height), 320, 300) ];
//add additional properties you need to add here
[self.View addSubview:youNewView];
}
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:newView cache:YES];
[UIView commitAnimations];
else
{
[UIView animateWithDuration:.5 animations:^{
newView.frame = CGRectMake(newView.frame.origin.x, -210, myPicker.frame.size.width, newView.frame.size.height);
} completion:^(BOOL finished) {
[newView removeFromSuperview];
}];
}
答案 1 :(得分:-1)
[UIView animateWithDuration:0.5 animations:^{
self.view.frame = CGRectMake(self.view.frame.origin.x,
self.view.frame.size.height,
self.view.frame.size.width,
self.view.frame.size.height);
[self.view layoutIfNeeded];
}];
请试试这个,这对我有用。