gpt4 book ai didi

iPhone iOS 如何就地翻转/反射(reflect)任何 UIView?

转载 作者:可可西里 更新时间:2023-11-01 03:13:45 27 4
gpt4 key购买 nike

我知道如何通过在其边界内重新绘制来翻转/反射/旋转 UIImage。

- (IBAction)reflectImageView:(UIImageView)imageView {

UIGraphicsBeginImageContextWithOptions(imageView.bounds.size, NO, 0.0);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextScaleCTM(context, 1.0, -1.0);
CGContextTranslateCTM(context, 0.0, -imageView.bounds.size.height);


[imageView.layer renderInContext:context];
imageView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

}

但是我如何为任何 UIView 创建“翻转/反射”效果,最好将其中心保持在与以前相同的位置?

谢谢!

最佳答案

 [UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];
[UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.activeView cache:YES];
// [self.activeView removeFromSuperview];
[UIView commitAnimations];

NSNumber* isReflected = [self.activeView.attributedView.attributes valueForKey:kIsReflected];
if(isReflected.boolValue)
{
self.activeView.transform = CGAffineTransformMakeScale(1,1);
[self.activeView.attributedView.attributes setValue: [NSNumber numberWithBool:NO] forKey:kIsReflected];
}else {
//do reflection
self.activeView.transform = CGAffineTransformMakeScale(-1,1);
[self.activeView.attributedView.attributes setValue: [NSNumber numberWithBool:YES] forKey:kIsReflected];
}

以上代码用于 UIView 动画。您将在其中获得各种类型动画的选项。

关于iPhone iOS 如何就地翻转/反射(reflect)任何 UIView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10685422/

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