我知道如何通过在其边界内重新绘制 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 动画。您将在其中获得各种类型动画的选项。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)