我有一个设置为隐藏的UITextField,当我点击搜索按钮时我想让它可见但是我想创建一个类似幻灯片的动画,如果我正在使用它是否可以重新创建这个效果的autoLayout?
我用于动画的代码是当前的(它创建了一个淡入效果):
if(!currentSrcState)
{
_searchField.hidden = NO;
[UIView animateWithDuration:0.3
delay:0.0
options:UIViewAnimationOptionTransitionCurlDown
animations:^ {
_searchField.alpha = 1.0;
}
completion:nil];
currentSrcState = YES;
}
else
{
[UIView animateWithDuration:0.3
delay:0.0
options:UIViewAnimationOptionTransitionCurlDown
animations:^ {
_searchField.alpha = 0;
}
completion:^(BOOL finished){
_searchField.hidden = YES;
}];
currentSrcState = NO;
}
我想要实现的是,当_searchField
被隐藏时,重新计算约束以便移动搜索字段下的内容
答案 0 :(得分:0)
不是将按钮设置为隐藏,而是在加载视图之前将其alpha值设置为0.0。然后将您的代码更改为:
if(!currentSrcState)
{
[UIView animateWithDuration:0.3
delay:0.0
options:UIViewAnimationOptionTransitionCurlDown
animations:^ {
_searchField.alpha = 1.0;
}
completion:nil];
currentSrcState = YES;
}
else
{
[UIView animateWithDuration:0.3
delay:0.0
options:UIViewAnimationOptionTransitionCurlDown
animations:^ {
_searchField.alpha = 0.0;
}
completion:nil];
currentSrcState = NO;
}