简体   繁体   English

带查询的iOS Segue动画初学者

[英]iOS Segue Animation Beginner with a query

Okay guys/gals, here's what I'm looking to do, I'd love some pointers to a good tutorial or a good explanation on how to do this. 好的,伙计们/加尔斯,这就是我想要做的事情,我很乐意为您提供一些指向良好教程或如何做到这一点的很好的说明。 As much as I'd love someone to post code here, I need to learn how to do this for future projects and overall feel good points.(I've searched myself but could only find swift tutorials which were similar but not the same) 尽管我希望有人在这里发布代码,但我需要学习如何为将来的项目做这件事,并且总体上感觉很好(我进行了自我搜索,但只能找到相似但不相同的快速教程)。

Imagine a screen with a circular button in the middle, wait you don't have to 想象一下中间有一个圆形按钮的屏幕,等一下您不必 中间有按钮的大图片

Sorry about the size, I want to press that button and perform a segue which expands from that button, eventually filling the screen with the new red screen. 抱歉,我要按下该按钮,然后执行从该按钮扩展的顺序,最终用新的红色屏幕填充屏幕。 So in essence the button grows and fill the screen but really I'm transitioning to a new screen. 因此,从本质上讲,按钮会增长并填满整个屏幕,但实际上我正在过渡到新屏幕。

Any pointers greatly appreciated. 任何指针,不胜感激。 Thanks. 谢谢。

A minor detail: this is the only screen on storyboard at present 较小的细节:这是目前故事板上的唯一屏幕

I had to do a couple of non-obvious things to make this work. 为了完成这项工作,我不得不做一些不太明显的事情。 First, get rid of button constraints in the storyboard. 首先,摆脱情节提要中的按钮约束。 Second, add a line to my viewDidLoad to derive constraints. 其次,在viewDidLoad添加一行以导出约束。

- (void)viewDidLoad {
    [super viewDidLoad];
    self.redButton.translatesAutoresizingMaskIntoConstraints = YES;
}

Then, for the actual effect I create an animation when the button is pressed. 然后,为了获得实际效果,按下按钮时会创建一个动画。 The animated:NO bit in the completion handler prevents extra visual noise. 完成处理程序中的animated:NO位可防止产生额外的视觉干扰。

- (IBAction)redButtonTapped:(id)sender {
    [UIView animateWithDuration:3.0 animations:^{
        self.redButton.frame = self.view.frame;
    } completion:^(BOOL finished) {
        UIViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"redController"];
        [self presentViewController:vc animated:NO completion:nil];
    }];
}

I used a simple button object for this. 我为此使用了一个简单的按钮对象。 To make it work with a round image, you may have to play with the new frame size a bit. 为了使其与圆形图像一起使用,您可能必须稍微调整一下新的帧尺寸。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM