我想旋转一个矩形,使底部保持固定,顶部向左和向右移动到给定的范围。有点像这个老式的泡泡射击游戏:http://prntscr.com/ab05a8 这就是 id 基本上需要矩形做的事情:http://prntscr.com/ab05om
最佳答案
假设您的矩形是 UIView
的实例,您可以将其 anchor 设置为按钮边缘的中间:
yourView.layer.anchorPoint = CGPoint(x: 0.5, y: 1.0)
然后,您可以使用 CATransform3D
旋转其图层
。例如 45 度:
var transform = yourView.layer.transform
transform = CATransform3DRotate(transform, CGFloat(45.0 * M_PI / 180.0), 0.0, 0.0, 1.0)
yourView.layer.transform = transform
关于swift - 有谁知道如何让这个泡泡射击游戏快速移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35791859/