joshdhenry / SpinWheelControl

An inertial spinning wheel UI control that allows selection of an item. Cocoapod written in Swift.
BSD 3-Clause "New" or "Revised" License
73 stars 25 forks source link

Having trouble changing wedge color #1

Closed latne1ec closed 7 years ago

latne1ec commented 7 years ago

Thanks for the lib! You're saving me a ton of time.

I've tried setting the wedge background color directly in wedgeForSliceAtIndex but it isn't working

How do you modify the color of each wedge?

joshdhenry commented 7 years ago

Thanks for trying it out. It's still in it's early stages so I hope you can make use of it. I love to get your feedback.

First of all, make sure you are using the newest version, v0.1.5. I just updated it yesterday and adjusted some issues with customizing wedge shapes and labels.

What I've done in my practice apps is to create an array of colors like so: let colorPalette: [UIColor] = [UIColor.blue, UIColor.brown, UIColor.cyan, UIColor.darkGray, UIColor.green, UIColor.magenta, UIColor.red, UIColor.orange, UIColor.black, UIColor.gray, UIColor.lightGray, UIColor.purple, UIColor.yellow, UIColor.white]

Then in wedgeForSliceAtIndex, setting the color like so: let wedge = SpinWheelWedge()
wedge.shape.fillColor = colorPalette[Int(index)].cgColor

You can also set the wedge's label like so: wedge.label.text = "Label #" + String(index)

Then close out the function by returning the wedge: return wedge

Hope this helps. I'll try to get an example app uploaded in the near future.

latne1ec commented 7 years ago

My notifications are sent to an old email so I am just now seeing this. Thanks a ton for the detailed info, implementing now!

Cheers!