gpt4 book ai didi

iphone - 带有动画的 UIButton 图像按钮

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:23:44 24 4
gpt4 key购买 nike

我有一个白色图像按钮。当我点击时,它应该通过从底部到顶部的动画变为黄色按钮图像,如果我再次单击黄色按钮图像它必须从上到下动画并变为白色图像按钮图像。

这是我尝试过的:

    float originalY = btn.frame.origin.y; 
float originalH = btn.bounds.size.height;

[UIView animateWithDuration:3.0f delay:1.0f options:UIViewAnimationOptionTransitionFlipFromBottom animations:^{

btn.frame = CGRectMake(btn.frame.origin.x, (originalY + originalH), btn.bounds.size.width, 0);

[btn setBackgroundImage:[UIImage imageNamed:@"yellowimg.png"] forState:UIControlStateNormal];

[btn setTitleColor:[[UIColor alloc]initWithRed:38.0/255.0 green:38.0/255.0 blue:38.0/255.0 alpha:1.0] forState:UIControlStateNormal];

}
completion:^(BOOL finished) {
}];

最佳答案

btn.frame = CGRectMake(btn.frame.origin.x, (originalY + originalH), btn.bounds.size.width, 0);

此方法将使您的按钮具有 height = 0。如果你想 curl (翻转)你的按钮并拥有从第一个出现的"new"按钮,我知道你应该使用类似的东西

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:firstView cache:YES];
[firstView addSubview:secondView];
[UIView commitAnimations];

关于iphone - 带有动画的 UIButton 图像按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13271374/

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