Ios 如何使形状绕其轴旋转?
六边形会旋转,但它不会停留在原地并旋转。我需要改变什么才能使它在每次单击按钮时顺时针旋转一次Ios 如何使形状绕其轴旋转?,ios,swift,Ios,Swift,六边形会旋转,但它不会停留在原地并旋转。我需要改变什么才能使它在每次单击按钮时顺时针旋转一次 shape6 = CAShapeLayer() view.layer.addSublayer(shape6) shape6.opacity = 0.5 shape6.lineWidth = 2 shape6.lineJoin = kCALineJoinMiter shape6.strokeColor = UIColor(hue: 0.786, satura
shape6 = CAShapeLayer()
view.layer.addSublayer(shape6)
shape6.opacity = 0.5
shape6.lineWidth = 2
shape6.lineJoin = kCALineJoinMiter
shape6.strokeColor = UIColor(hue: 0.786, saturation: 0.79, brightness: 0.53, alpha: 1.0).CGColor
shape6.fillColor = UIColor(hue: 0, saturation: 0, brightness: 0, alpha: 0).CGColor
path6 = UIBezierPath()
path6.moveToPoint(CGPointMake(35,430))
path6.addLineToPoint(CGPointMake(80, 300))
path6.closePath()
shape6.path = path6.CGPath
@IBAction func ispin(sender: AnyObject) {
UIView.animateWithDuration(1.0, animations: ({
self.shape1.transform = CATransform3DMakeRotation(30, 150, 400, 20)
self.shape2.transform = CATransform3DMakeRotation(30, 150, 400, 20)
self.shape3.transform = CATransform3DMakeRotation(30, 150, 400, 20)
self.shape4.transform = CATransform3DMakeRotation(30, 150, 400, 20)
self.shape5.transform = CATransform3DMakeRotation(30, 150, 400, 20)
self.shape6.transform = CATransform3DMakeRotation(30, 150, 400, 20)
}))
}
尝试设置形状的定位点
shape6
:
shape6.anchorPoint = CGPointMake(0.5, 0.5)
你说它不在原来的位置上是什么意思?它会移动到不同的位置,但我希望它保持在一个位置,每次单击按钮时,六边形将旋转x度并保持在同一位置。它不会在x、y或z轴上移动。请为您的约束发布一张图片,我将帮助您当前的约束在上面。您可以上传动画的视频吗?