我在 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;
谁能解释一下为什么?我怎样才能在相同的代码中正常工作?
最佳答案
参见文章 http://revealapp.com/blog/constraints-and-transforms.html
它解释了 iOS7 中仿射变换错误的问题。对于简单的单词,您需要使用 [UIScreen mainScreen].scale
关于ios8 - CGAffineTransformMakeTranslation 和 CGAffineTransformScale 变换在 ios7 和 ios8 中不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26051392/