In this video, you will learn how to build a custom UIControl in Swift, specifically a Segmented Control. Xcode 6+ introduced the concept of @IBDesignable and @IBInspectable where you can create/modify your control at design time and see the changes in the Storyboard.

Really cool huh? Watch the video to learn how.

What if you could spruce up the control with some cool animations? We added some animations to the thumb view so it springs to the final location. See the GIF image below. Want to learn how to do this? Download the sample project below to see how to implement the Custom animations.

Get access to the source code here or click here to see the Mega template with all the other controls

segmented-gif

This tutorial will show you how to create a custom iOS segmented control in Swift using UI IBDesignable and IBInspectable

5 comments

  1. Batman

    Hey,
    thanks for the tutorial. It’s very great. However i found a bug in your source code. If you add an array with your own labels the current ones sometimes still stay in there because the constraints are not updated to all new items. Maybe you could add this to your source code archive as well.

    Thanks and greetings
    Bruce

  2. Yesa

    Hello , I cant set the initial selected index. It always shows me that selected image index is 0! Why is that so?

  3. Igrica

    Great plug-in but like Jim I can see the Registered Users but can’t bring up the pages they have visited. Did you get auornd to updating the article?

  4. Pingback: Swipe between various table views added as subviews of a single View Controller using segment control - BlogoSfera