【问题标题】:CGAffineTransformMakeTranslation and CGAffineTransformScale transforms different in ios7 and ios8CGAffineTransformMakeTranslation 和 CGAffineTransformScale 在 ios7 和 ios8 中的变换不同
【发布时间】:2014-09-26 03:02:02
【问题描述】:

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

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

【问题讨论】:

    标签: ios8 zooming cgaffinetransform cgaffinetransformscale


    【解决方案1】:

    见文章http://revealapp.com/blog/constraints-and-transforms.html

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-14
      • 1970-01-01
      • 2014-11-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-15
      • 2014-12-05
      相关资源
      最近更新 更多