六角形旋转,但不会保持原位旋转。我需要更改什么才能使其每次单击按钮一次都顺时针旋转。
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)
关于ios - 如何使形状绕其轴旋转?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31231159/