未调用 UIView 转换动画

UIView transform animations not being called

目前有一个视图我正在尝试同时平移(移动)、旋转和缩放视图。出于如此奇怪的原因,当我将比例放在底部时,它只会缩放它。但是,当我更改顺序并将缩放放在第一位时,它会正确旋转和平移视图,但视图的比例会短暂更改为正确的比例,然后再变回其原始大小。我需要它保持它的缩放形式。这是代码:

class ViewController: UIViewController {


 let newView = UIView(frame: CGRect(x: 10, y: 10, width: 100, height: 100))


  override func viewDidLoad() {
    super.viewDidLoad()


    self.view.addSubview(newView)


    UIView.animate(withDuration: 1.0, animations: {


      self.newView.transform = CGAffineTransform(translationX: 50, y: 70)//translation
      self.newView.transform = CGAffineTransform(rotationAngle: -CGFloat.pi / 2)//rotation
      self.newView.transform = CGAffineTransform(scaleX: 1, y: 0.5)//scale
    })
  }
}

尝试先组合变换,然后一次应用它们:

    let translate = CGAffineTransform(translationX: 50, y: 70)

    UIView.animate(withDuration: 1.0, animations: {
        self.view.transform =  translate.rotated(by: -CGFloat.pi / 2).scaledBy(x: 1, y: 0.5)
    })