CGAffineTransformMakeTranslation和CGAffineTransformScale在ios7和ios8中进行不同的转换

时间:2014-09-26 03:02:03

标签: ios8 zoom cgaffinetransform cgaffinetransformscale

我在viewcontroller中有一个UITableView,想要在viewcontroller的中心缩小。它在ios7中工作正常,如下代码:

CGSize appSize = [[UIScreen mainScreen] applicationFrame].size;
CGAffineTransform affineMatrix = CGAffineTransformMakeTranslation(appSize.width/2, 20);
affineMatrix = CGAffineTransformScale(affineMatrix, 0.5, 0.5);
self.transform = affineMatrix;

更新到ios8之后,代码可能会这样工作正常,但在ios7中无效:

CGAffineTransform affineMatrix = CGAffineTransformMakeScale(0.5, 0.5);
affineMatrix = CGAffineTransformConcat(affineMatrix,CGAffineTransformMakeTranslation(0, -appSize.height/2+40));
self.transform = affineMatrix;

谁能解释为什么?我怎样才能在相同的代码中正常工作?

1 个答案:

答案 0 :(得分:0)

请参阅文章http://revealapp.com/blog/constraints-and-transforms.html

它解释了iOS7中关于仿射变换错误的问题。对于简单的单词,您需要使用[UIScreen mainScreen].scale

在iOS 7上手动将点转换为视网膜设备上的像素