gpt4 book ai didi

iphone - 如何翻转 UIImageView?

转载 作者:行者123 更新时间:2023-12-03 18:33:24 25 4
gpt4 key购买 nike

如何翻转 UIImageView?

最佳答案

创建两个UIImageView frontImageView & backImageView

创建一个 UIView 容器 View 来包含 UIImageView

在开头显示 frontImageView。

翻转后显示backImageView

代码:

// before flip
frontImageView = [[UIImageView alloc] initWithImage:[UIImage
imageNamed:@"test.png"]];

containerView = [[UIView alloc] initWithFrame:frontImageView.bounds];
containerView.center = CGPointMake(200,200);

[self.view addSubview:containerView];
[containerView addSubview:frontImageView];

-(IBAction)flipButtonClicked:(id)sender
{
backImageView = [[UIImageView alloc] initWithImage:[UIImage
imageNamed:@"cardback.png"]];
backImageView.center = frontImageView.center;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
forView:containerView
cache:YES];
[frontImageView removeFromSuperview];
[containerView addSubview:backImageView];
[UIView commitAnimations];
}

关于iphone - 如何翻转 UIImageView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1194752/

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