Reproducing Popular iOS Controls - Part 5: | Ray Wenderlich Videos

In this challenge you'll animate the background color for the left and right screens as the user scrolls.

This is a companion discussion topic for the original entry at

Amazing video Lea :slight_smile:, I have a question regarding the way you implemented the ColoredView protocol conformance.

  1. Why did you set the controllerColor property on the ViewController implementation and not in the extension, like:
    extension DiscoverViewController: ColoredView {
    var controllerColor: UIColor {
    return UIColor(red: 0.59, green: 0.23, blue: 0.96, alpha: 1.0)
  2. Why is the controllerColor property get, set if we are only getting it.

@leamars Can you please help with this when you get a chance? Thank you - much appreciated! :]

@lmag94 Im not a hundred percent sure, this is only speculation. But the reason im gathering from my limited knowledge of fictional programing is that you want to group your code in one place. That cuts down on lines you need to write and makes it easier to understand. The bases of this is a protocol is a instance thats out of memory after running it. a class stays running until its told to end. The color property is set so the program now and to execute when that is called in the program. look up functional programing, that will explain a TON. Im so sorry I cant go into more detail, im currently learning this. It seems as if you are very knowledgeable, keep it up!!!

I think you probably meant functional programming there, but I feel like fictional programming would be equally as awesome, if not more so!

Yes, I do try to chunk my code into small little pieces. Rule of thumb - if a function is so long that you have to scroll up and down to see it whole, it’s too long! This isn’t necessarily functional programming, just good practice.

Anyways, back to the original question from @lmag94 about the ColoredView protocol implementation.

Honestly, you’re totally on point there. That’s a much better way of implementing the protocol and the classes that conform to it.

This implementation could have easily been how you described it. I believe that when I was developing the app, I had some other ideas of what I would do with it, and then I never went back to it to change it so it would make more sense once I decided on the final trajectory for the project. :slight_smile:

1 Like