Iphone Can';翻转CGT图像

Iphone Can';翻转CGT图像,iphone,core-animation,Iphone,Core Animation,我需要做的是从左到右翻转cgimagerf,它是CALayer的conntents属性。我一直在谷歌上彻底搜索,想找到一种直接翻页的方法,但是没有找到。所以我决定翻转UIImage,然后将其CGImage属性设置为CALayer的内容 所以我所做的是: UIImage *src = [UIImage imageNamed:@"res/images/lizard.png"]; src = [UIImage imageWithCGImage:src.CGImage scale:1.0 orient

我需要做的是从左到右翻转cgimagerf,它是CALayer的conntents属性。我一直在谷歌上彻底搜索,想找到一种直接翻页的方法,但是没有找到。所以我决定翻转UIImage,然后将其CGImage属性设置为CALayer的内容

所以我所做的是:

 UIImage *src = [UIImage imageNamed:@"res/images/lizard.png"];
src = [UIImage imageWithCGImage:src.CGImage scale:1.0 orientation:UIImageOrientationRightMirrored];
UIImageView *test = [[UIImageView alloc] initWithImage:src];
[test setFrame:CGRectMake(20, 20, 50, 50)];
[self.view addSubview:test];

[lizard.layer setContents:((id)test.image.CGImage)];
但这是徒劳的,层仍然没有翻转。我接下来做的是:

UIImage *src = [UIImage imageNamed:@"res/images/lizard.png"];
UIImageView *test = [[UIImageView alloc] initWithImage:src];
[test setFrame:CGRectMake(20, 20, 50, 50)];
[self.view addSubview:test];
test.transform   = CGAffineTransformIdentity;
test.transform   = CGAffineTransformMakeScale(-1.0, 1.0);

[lizard.layer setContents:((id)test.image.CGImage)];
但不幸的是,它仍然不能满足我的需要。UIImageView名为
test
按预期显示-它已翻转,但lizard.layer的内容未翻转。怎么会这样? 你能帮我吗

1) 有没有一个正常的方式来翻转CALayer的内容


2) 如果没有,那么如何翻转CGImageRef以正确设置内容?

您已将转换应用于测试imageview,而不是其图像。因此,当您将图像指定给其他未翻转的层时,您不能期望翻转输出

将变换应用于lizard.layer。你会明白的

[lizard.layer  setAffineTransform:CGAffineTransformIdentity];
[lizard.layer setAffineTransform: CGAffineTransformMakeScale(-1.0, 1.0)];

如何将转换应用于lizard.layer?您可以使用以下方法将转换分配给CAlayer—(void)setAffineTransform:(CGAffineTransform)m;它工作,但不是我需要它如何工作。它翻转图像,但它翻转它。。。我不知道如何描述。。。图像不仅仅是翻转的,它从顶部和底部到中心消失,然后从中心到底部和顶部出现,真的很难解释,但它不像我需要的那样工作。你能准确地发布你需要的图像吗?。我可以发布图像,但我不能发布翻转图像的移动。如果将setAffineTransform应用于具有任何图像的层,您将看到我所说的内容