How to add vibrancy effect to UISegmentedControl but not to its labels?

532 Views Asked by At

In notification centre, the top segmented control looks to be drawn with a vibrancy effect. However, its labels (Today and Notifications) appear to be regular, opaque colours. How can I reproduce this?

1

There are 1 best solutions below

0
On

First, Add UISegmentedControl to UIVisualEffectView, the one with vibrancy.

Then, Add another Identical UISegmentedControl just above the Previous Segmented Control but not in the same view, a view above or anywhere.

Set the TintColor of The upperSegmentedControl to UIColor.clearcolor()

Set UserInteractionEnabled to false

And then,

upperSegmentedControl.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.whiteColor()], forState: UIControlState.Normal)

upperSegmentedControl.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.clearColor()], forState: UIControlState.Selected)

Important NOTE : Keep both segments in sync.

This is not the Smartest Solution, But it works.