3

我在 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;

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

4

1 回答 1

0

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

它解释了iOS7中仿射变换错误的问题。简单来说,您需要在 iOS 7 上的视网膜设备上使用手动将点转换为像素[UIScreen mainScreen].scale

于 2015-09-18T17:10:25.197 回答