gpt4 book ai didi

ios - 图像动画

转载 作者:行者123 更新时间:2023-12-04 18:43:19 25 4
gpt4 key购买 nike

我有一个 scrollviewimageview subview to scrollview.on a button click I subview another imageview 并通过

将该图像发送到该现有图像的背面
[nextImageView sendSubviewToBack:firstImageView];

我希望 firstImageView 在单击按钮时淡入淡出并显示第二个图像,在单击按钮时我也希望发生相反的情况

最佳答案

好的,据我了解,您希望通过单击按钮“切换”输入和输出几个图像。尝试以下操作,其中“img1”是第一个 UIImageView,“img2”是第二个 UIImageView。这称为 animation block .

-(IBAction)showSecondImg:(id)sender {

// Some code to add Img2 subview behind Img1..

[UIImageView animateWithDuration:1 // <-- Number of seconds
animations:^{
img1.alpha = 0; // <-- fade out in 1 second and shows Img2 below it
//add other animations here, like background color, etc. if needed.
}
];
}

-(IBAction)showFirstImg:(id)sender {

// gradually fades the first UIImageView back on top
[UIImageView animateWithDuration:1
animations:^{
img1.alpha = 1;
}
];
}

关于ios - 图像动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8665813/

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