Last active
June 24, 2024 02:19
-
-
Save ham118/2359f00d3d87cdaf655ca6cdae856d1d to your computer and use it in GitHub Desktop.
To set customize UISlider height | Swift 4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//To set UISlider height, (which is by default not provided by UIKit framework) | |
//Steps: | |
//1. Add "CustomSlider" class in your swift file. | |
//2. Set "CustomSlider" class name into UISlider control from interface builder. | |
//3. Set "trackLineHeight" value as per requirment. | |
class CustomSlider: UISlider { | |
//Set line height value from Interface Builder,i.e. here ten is default value | |
@IBInspectable var trackLineHeight: CGFloat = 10 | |
//Set custom size of track so here override trackRect function of slider control | |
override func trackRect(forBounds bound: CGRect) -> CGRect { | |
return CGRect(origin: bound.origin, size: CGSize(width: bound.width, height: trackLineHeight)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment