gpt4 book ai didi

ios - UIView animateWithDuration 不适用于 Rect 宽度/高度动画

转载 作者:行者123 更新时间:2023-11-28 17:33:18 26 4
gpt4 key购买 nike

以下代码有效。它很好地为所有这些组件设置了动画

CGRect logoRect = self.logoImageView.frame;
CGRect loginBackgroundRect = self.loginControlsBkImageView.frame;
CGRect loginButtonRect = self.loginButton.frame;
CGRect tableViewRect = self.tableView.frame;
CGRect forgotPasswordRect = self.forgotButton.frame;
CGRect signupButtonRect = self.signUpButton.frame;


if (!iPhone) {

// ipad keyboard-on-screen re-layout

logoRect.origin.y-= 60;
loginBackgroundRect.origin.y-= 110;
loginButtonRect.origin.y-=110;
tableViewRect.origin.y-=110;
forgotPasswordRect.origin.y-=110;
signupButtonRect.origin.y-=200;

}
else {

// iphone keyboard-on-screen re-layout

if (portrait) {
logoRect.origin.y-=17;
logoRect.origin.x-=50;
loginBackgroundRect.origin.y-= 70;
loginButtonRect.origin.y-=70;
tableViewRect.origin.y-=70;
forgotPasswordRect.origin.y-=70;
//signupButtonRect.origin.y+=200; // get off screen!
} else {
logoRect.origin.y-= 30;
loginBackgroundRect.origin.y-= 25;
loginButtonRect.origin.y-=25;
tableViewRect.origin.y-=25;
}
}


[UIView animateWithDuration:0.2f
delay:0.0f
options:UIViewAnimationOptionCurveEaseIn
animations:^(void) {
self.logoImageView.frame = logoRect;
self.loginControlsBkImageView.frame = loginBackgroundRect;
self.loginButton.frame = loginButtonRect;
self.tableView.frame = tableViewRect;
self.forgotButton.frame = forgotPasswordRect;
self.signUpButton.frame = signupButtonRect;
}
completion:NULL];

采用以下代码并添加一行(见下文)来为 logoImageView 的 WIDTH 设置动画......然后吹气......只有 logoImageView 动画有效 - 其余的根本不会移动。就好像帧大小动画导致其他所有内容在同一个动画 block 中都没有动画一样。

if (portrait) {
logoRect.origin.y-=17;
logoRect.origin.x-=50;
loginBackgroundRect.origin.y-= 70;
loginButtonRect.origin.y-=70;
tableViewRect.origin.y-=70;
forgotPasswordRect.origin.y-=70;
//signupButtonRect.origin.y+=200; // get off screen!
} else {
logoRect.origin.y-= 30;
logoRect.size.width-= 30; // <------- LINE BEING ADDED HERE

loginBackgroundRect.origin.y-= 25;
loginButtonRect.origin.y-=25;
tableViewRect.origin.y-=25;
}

我在这里不知所措。有谁知道这是怎么回事吗?

最佳答案

尝试改变整个框架,而不仅仅是宽度。它应该工作。

在提交动画之前放置这些行(不是在 block 中):

self.logoImageView.frame = logoRect;
etc.

而不是使用动画方法尝试以这种方式使用提交动画:

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];
// Here some more animation settings
// Here your animations
[UIView commitAnimations];

关于ios - UIView animateWithDuration 不适用于 Rect 宽度/高度动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10596997/

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