iPhone iOS如何翻转/反映任何UIView就位? [英] iPhone iOS how to flip/reflect any UIView in - place?

查看:155
本文介绍了iPhone iOS如何翻转/反映任何UIView就位?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何通过在UIImage的范围内重新绘制它来翻转/反射/旋转它。

I know how to flip/reflect/rotate a UIImage by re-drawing it within it's bounds.

- (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,最好保持它的中心位置和以前一样?

But how do I create a "flip/reflect" effect for any UIView, preferably keeping it's center in the same position as before?

谢谢!

推荐答案

 [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动画。您将获得各种类型动画的选项。

Above code is used for UIView Animation. Where you will get an options for various type animation.

这篇关于iPhone iOS如何翻转/反映任何UIView就位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆