【问题标题】:Rotate UIImageView 90degrees - Swift将 UIImageView 旋转 90 度 - Swift
【发布时间】:2020-09-29 20:51:11
【问题描述】:

我正在尝试让 UIImageView 旋转,所以它会从这个角度看(在方面适合):

对此:(对不起规模)

这是我用来尝试旋转 imageView 的代码:

// rotate the imageView
   let transform = CGAffineTransform(rotationAngle: .pi/2)
   self.imageView.transform = transform

这种方法有效,但是会截掉大部分图像,看起来像这样:

我该怎么做?提前致谢!

【问题讨论】:

  • 为什么不旋转图像视图,而不是旋转图像?这有意义吗?
  • @matt 不,因为我也想用它来旋转添加到 UIView 中的 AVPlayerLayer。但是,如果你可以看看我的这篇文章:stackoverflow.com/questions/64110082/… 谢谢!

标签: ios swift xcode rotation imageview


【解决方案1】:

尝试像这样改变变换旋转:

yourImageView.transform = self.yourImageView.transform.rotated(by: .pi / 2)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-03-22
    • 1970-01-01
    • 2015-03-22
    • 2022-01-13
    • 2011-09-24
    • 2020-09-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多