gpt4 book ai didi

iphone - iOS 开发 : How can I animate the addition/removal of form controls in a view?

转载 作者:行者123 更新时间:2023-11-28 20:38:39 25 4
gpt4 key购买 nike

我有一个登录 View ,其中包含用户名和密码文本字段以及两个用于“登录”和“创建新帐户”的按钮。目前,我拥有它,以便如果用户单击“创建新帐户”按钮,它会加载一个具有相同控件的新 View ,除了删除“登录”按钮并添加“确认密码”文本字段。是否可以将这些控件添加/删除到同一 View 而不是加载新 View ?如果是这样,是否也可以对其进行动画处理?

非常感谢您的智慧!

最佳答案

您可以尝试一个简单的 UIView 动画。我不认为你可以为 addSubview:removeFromSuperview: 制作动画,但你可以为 alpha 中的变化制作动画:

// add confirmPasswordButton to the view, alpha=0 (invisible)
[confirmPasswordButton setAlpha:0.0];
[self.view addSubview:confirmPasswordButton];

[UIView beginAnimations:@"switchButtons" context:NULL];
[UIView setAnimationDuration:1.0];
[confirmPasswordButton setAlpha:1.0];
[signinButton setAlpha:0.0];
[UIView commitAnimations];

这些是基础。查看 Apple 的文档以获取有关回调、使用 block 、更多动画参数等的更多详细信息: https://developer.apple.com/library/ios/#documentation/WindowsViews/Conceptual/ViewPG_iPhoneOS/AnimatingViews/AnimatingViews.html#//apple_ref/doc/uid/TP40009503-CH6-SW1

关于iphone - iOS 开发 : How can I animate the addition/removal of form controls in a view?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9505188/

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