I want to add a view on top of a custom segmented control. Below is my code.
import UIKit
class CustomSegmentedControl: UISegmentedControl {
    override func awakeFromNib() {
        let overlayView = UIView(frame: frame)
        overlayView.backgroundColor = UIColor.yellowColor()
        superview?.addSubview(overlayView)
    }
}
But strangely it doesn't overlay the segmented control properly.

I can't figure out why this is happening. Any suggestion on how to resolve this?
Thank you.