iPhone的iOS如何翻转/reflection任何UIView的地方?

我知道如何翻转/reflection/旋转的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创build一个“翻转/reflection”效果,最好是保持与之前一样的位置?

谢谢!

  [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]; } 

以上代码用于UIViewanimation。 在哪里你会得到各种types的animation选项。

您可以制作任何视图的“截图”

 UIGraphicsBeginImageContext(self.view.frame.size); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); 

然后翻转UIImage并添加一个UIImageView与视图下面的结果图像。