You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Coud you please help how to implement the colorWheelDidChangeColor method in swift 2?
How do i set the delegate to self? That doesn't work: cw!.delegate = self
currentColor is a variable and not a method hence you need to use colorWheel.currentColor
You haven't set your ViewController to conform to ISColorWheelDelegate
Solution
I created a global variable as so: var colorWheelView: ISColorWheel = ISColorWheel()
Then after specifying its dimensions, I set its delegate; colorWheelView.delegate = self. I'd recommend you do this before colorWheelView.continuous = true
Conform Class Delegation I
You can make an extension of your class which implements the ISColorWheelDelegate as such:
Side Note
If you opt the first option to set your delegate, extensions are added outside of the class. Its up to you whether you keep them before or after the class.
Two Cents
If you follow the Swift Style Guideline, the first delegation option is favorable because you separate respective 'library' (for luck of a better term) implementations from the core class implementations plus it makes your code more readable.
With the second option, you're pretty much just dumping all the code inside and you can imagine how tedious it'll get once you have multiple delegations and datasources to conform to.
Hello
Coud you please help how to implement the colorWheelDidChangeColor method in swift 2?
How do i set the delegate to self? That doesn't work: cw!.delegate = self
I tried it with this code:
var cw: ISColorWheel?
cw = ISColorWheel(frame:CGRectMake(size!.width / 2 - wheelSize!.width / 2, size!.height * 0.1, wheelSize!.width, wheelSize!.height))
cw!.continuous = true
self.view.addSubview(cw!)
And the action method:
func colorWheelDidChangeColor(colorWheel: ISColorWheel) {
view.backgroundColor = colorWheel.currentColor()
}
Thank you for your help.
Simon
The text was updated successfully, but these errors were encountered: