Closed marcosgriselli closed 6 years ago
Update: I'm rotating the UIImage
before adding it to the wedge and works perfectly for every case now.
I'm having issues finding the correct rotation for the label at each case. At the moment I got it to work with only a 4 wedge wheel with this transform:
public func configureWedgeLabel(index: UInt, width: CGFloat, position: CGPoint, radiansPerWedge: Radians) {
frame = CGRect(x: 0, y: 0, width: width, height: 30)
layer.anchorPoint = CGPoint(x: 0.5, y: 4.5)
layer.position = position
transform = CGAffineTransform(rotationAngle: radiansPerWedge * CGFloat(index + 1) + (radiansPerWedge / 2))
text = "wedge #\(index)"
setDefaultValues()
}
I haven’t yet attempted to add labels like that. I hope to try it this weekend and see if I can get something working.
Great, I'll be playing with it a little bit as well. Trying to add tap on wedge functionality. I'll send a PR if I get it correct.
Haven't forgot about this. Trying to catch up and merge pull requests and answer questions for this repo but it is taking longer than I thought.
Sorry for the delay, been busy! But this worked for me:
@objc public func configureWedgeLabel(index: UInt, width: CGFloat, position: CGPoint, radiansPerWedge: Radians) {
frame = CGRect(x: 0, y: 0, width: width, height: 30)
layer.anchorPoint = CGPoint(x: 0.5, y: 4.5)
layer.position = position
transform = CGAffineTransform(rotationAngle: radiansPerWedge * CGFloat(index) + (CGFloat.pi / 2) + (radiansPerWedge / 2))
text = "wedge #\(index)"
setDefaultValues()
}
Let me know if it works for you. I'd like to add it as a feature.
In the newest version, 0.2.0, spin wheels can now be inited with the orientation property of type WedgeLabelOrientation. This allows us to give the wedge label different positions and orientations. Currently WedgeLabelOrientation can either be .inOut or .around.
Re-edit as I realized the problem.
I want to display horizontal elements on the wedge rather than vertically. I added an UIImageView using a mask and following the
SpinWheelWedgeLabel
which works as expected but it rotates the image (the same way it rotates the label). This is what I'm trying to achieve.Should I be editing the transform or layer position? Or everything?