Group Group Group Group Group Group Group Group Group

Chapter 4 Challenge and constant binding

The solution for the challenge in Chapter 4 uses a constant binding for the alpha value. I’m not sure if this is necessary (works without) and moreover, from Apple’s documentation, a constant binding “can be useful when using a PreviewProvider” which sounds like it’s more to be used for testing.
Are there any benefits from the constant binding?
Moreover, the solution is a bit inconsistent in first (in makeUIView) setting the thumbTintColor-alpha and later in updateUIView setting the alpha for the whole component. The challenge states that the alpha of the thumb tint color should be modified.

hi Oliver! sorry for the delay in replying, this forum doesn’t always email me with new posts.

I used a constant binding because I didn’t know how else to send a computed value, as opposed to a State var.

alpha is a property of the ColorUISlider view and is used only to set slider.thumbTintColor in makeUIView(context:). updateUIView is just passing the property values to the UISlider.