TwicketSegmentedControl
TwicketSegmentedControl copied to clipboard
Add UIVisualEffectView to background
I'm wondering if it's at all possible to add a blur view to the background view. From what I understand, if a mask is set to a superview of a UIVisualEffectView it will fail as mentioned here: https://developer.apple.com/reference/uikit/uivisualeffectview. Not sure if this is the cause of the failure I get when I try.
You should be able to add a TwicketSegmentedControl as a subview of a UIVisualEffectView
This was working for me:
let visualEffectView = UIVisualEffectView(effect: UIBlurEffect(style: .light))
visualEffectView.frame = frame
view.addSubview(visualEffectView)
let segmentedControl = TwicketSegmentedControl(frame: visualEffectView.bounds)
segmentedControl.setSegmentItems(titles)
segmentedControl.delegate = self
segmentedControl.backgroundColor = .clear // This is important!
visualEffectView.addSubview(segmentedControl)