Open source project, UIControl subclass with capabilities of a segmented control, dynamically changing based on items passed in an array, it can handle text, images and colors.
https://medium.com/@jamesrochabrun/custom-control-open-source-in-swift-c54833e5abe9