Open emmet-temme opened 6 years ago
@emmet-temme I needed to change VerticalSlider to subclass UISlider to set the custom class property. After assigning, I could then change it back to subclassing from UIControl.
However, the control is still unusable in my application. I'm getting a "IBDesignable Build Failed" message, and the VerticalSlider class doesn't "take". All the attributes of the slider still appears as a UISlider -- not VerticalSlider. I'm still searching for a solution to this problem. The sample application from GitHub works, so there's some subtle difference between the sample code and mine even though VerticalSlider.swift is identical.
I'm using Xcode 9.2.
It turned out that to set the custom class you should not try to subclass a class derived from UISlider despite the author's suggestions. Instead, subclass a view, at which time the VerticalSlider, subclassed from UIControl will appear in the list of potential custom classes. I also needed to exit Xcode and delete DerivedData to eliminate a 'build failed' message.
1) The trackLength is being set before the subviews have resized causing strange results. This also adds support for change in orientation. 2) Needs a way to set the value otherwise it cannot be preset or used in a UICollectionView. 3) As noted above you must use a UIView not a UISlider and it must be the same width as the the thumb, currently 42.
added:
func setValue(value: CGFloat) { self.value = value setNeedsDisplay() }
override func layoutSubviews() { super.layoutSubviews() let tempValue = value trackLength = self.bounds.height - (self.thumbOffset * 2) self.value = tempValue setNeedsDisplay() }
Hello,
If I do so in your XCode Project, in the Identity Inspector I can only choose the VerticalUISlider class, but not the VerticalSlider class. How can i set the custom class property to VerticalSlider?
Im using XCode 9.2
Thanks