我怎样才能让我的视野缩小并消失?
当我的用户按下按钮时,我希望可见视图缩小并消失,从而显示下面的父视图。目前我有这个,它几乎可以工作:
-(void)deleteNoteTransition
{
self.view.userInteractionEnabled=NO;
[UIView beginAnimations:@"deleteNote" context:nil];
[UIView setAnimationDuration:0.6];
self.view.transform=CGAffineTransformMakeScale(0.01,0.01);
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:)];
[UIView commitAnimations];
}
- (void)animationDidStop:(NSString *)anim finished:(BOOL)flag
{
self.view.userInteractionEnabled=YES;
if ([anim isEqualToString:@"deleteNote"]) {
[self.navigationController popViewControllerAnimated:YES];
}
}
但是,这有两个问题:
- 缩小的视图不是“整个”视图 - 它不包括标题栏和工具栏。
- 视图缩小以显示纯白色背景,然后才会触发第二个方法,因此白色背景毫不客气地替换为父视图。
有没有一种方法可以包含整个屏幕并平滑地显示后面的父视图控制器,而无需涉及对于我当前的编程水平来说太复杂的 OpenGL 内容?
When my user presses a button, I want the visible view to shrink and disappear, revealing the parent view underneath. Currently I have this, which almost works:
-(void)deleteNoteTransition
{
self.view.userInteractionEnabled=NO;
[UIView beginAnimations:@"deleteNote" context:nil];
[UIView setAnimationDuration:0.6];
self.view.transform=CGAffineTransformMakeScale(0.01,0.01);
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:)];
[UIView commitAnimations];
}
- (void)animationDidStop:(NSString *)anim finished:(BOOL)flag
{
self.view.userInteractionEnabled=YES;
if ([anim isEqualToString:@"deleteNote"]) {
[self.navigationController popViewControllerAnimated:YES];
}
}
There are two problems with this, however:
- The view that does the shrinking is not the "whole" view - it does not include the title bar and toolbar.
- The view shrinks to reveal a plain white background, and only then is the second method triggered, so the white background is unceremoniously replaced with the parent view.
Is there a way to include the whole screen and smoothly reveal the parent view controller behind, without getting into OpenGL stuff which is far too complicated for my current level of programming?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这应该捕获您的整个视图:
将视图捕获到图像后,使用此方法缩放和淡入图像:
您可以从
[UIApplication sharedApplication]
获取窗口,或者将其添加为当前视图控制器的视图的子视图。This should capture your whole view:
Once your capture your view to an image, use this method to scale and fade the image:
You can get the window from the
[UIApplication sharedApplication]
, or just add it as a subview of the view of the current view controller.