gpt4 book ai didi

ios - 从指定点呈现模态 Controller

转载 作者:行者123 更新时间:2023-11-29 13:03:37 24 4
gpt4 key购买 nike

我在某些 viewController View 上有按钮。 touchUpInside: 方法呈现模态视图 Controller 。我想从点击按钮框架的中心展示它们。我怎样才能达到这个结果?我试过:

webController.view.transform = CGAffineTransformScale(CGAffineTransformIdentity, self.buuton.center.x, self.button.center.y);
[self presentViewController:webController animated:NO completion:^{
// some code
}];

但它损坏了我的用户界面。我也尝试使用[UIView beginAnimation],没有成功。

最佳答案

我用一个技巧实现了类似的效果,将 destvc.view 作为 subview 添加到 sourcevc.view,请参阅下面我的函数以进行缩放。

你可以只用视觉效果一样的技巧,最后展示你的vc,没有动画:

    +(void) animWithAlpha:(float)alpha view:(UIView*)view{
[UIView animateWithDuration:0.15
delay:0.0
options:UIViewAnimationOptionBeginFromCurrentState
animations:^{
view.alpha = alpha;
}
completion:^(BOOL fin) {}];
}


+(void) zoomIN:(UIViewController*)sourceViewController destination:(UIViewController*)destinationViewController fromPoint:(CGPoint)point{

[sourceViewController.view addSubview:destinationViewController.view];
[destinationViewController.view setFrame:sourceViewController.view.window.frame];
[destinationViewController.view setTransform:CGAffineTransformMakeScale(0.15, 0.1)];
destinationViewController.view.center = point;
sourceViewController.view.userInteractionEnabled=NO;
destinationViewController.view.alpha = 0.5;
[self animWithAlpha:1 view:destinationViewController.view];
[UIView animateWithDuration:0.4
delay:0.0
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
[destinationViewController.view setTransform:CGAffineTransformMakeScale(1, 1)];
destinationViewController.view.center = sourceViewController.view.center;
}
completion:^(BOOL finished){
if(finished){
[destinationViewController.view setTransform:CGAffineTransformMakeScale(1, 1)];
destinationViewController.view.center = sourceViewController.view.center;
sourceViewController.view.userInteractionEnabled=YES;
}
}];

}

+(void) zoomOUT:(UIViewController*)sourceViewController destination:(UIView*)destination toPoint:(CGPoint)point{
[sourceViewController.view setTransform:CGAffineTransformMakeScale(1.0, 1.0)];
[sourceViewController.parentViewController.view setUserInteractionEnabled:NO];
[destination setUserInteractionEnabled:NO];
[UIView animateWithDuration:0.4
delay:0.0
options:UIViewAnimationOptionCurveEaseOut
animations:^{
[sourceViewController.view setTransform:CGAffineTransformMakeScale(0.01, 0.01)];
[sourceViewController.view setAlpha:1.0];
sourceViewController.view.center = point;
}
completion:^(BOOL finished){
if(finished){
[sourceViewController.view setTransform:CGAffineTransformMakeScale(1.0, 1.0)];
[sourceViewController.view removeFromSuperview];
sourceViewController.view.center = point;
[destination setUserInteractionEnabled:YES];
}
}

关于ios - 从指定点呈现模态 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19180037/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com