TwicketSegmentedControl icon indicating copy to clipboard operation
TwicketSegmentedControl copied to clipboard

Add UIVisualEffectView to background

Open niazoff opened this issue 8 years ago • 1 comments

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.

niazoff avatar Jan 06 '17 17:01 niazoff

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)

polqf avatar Jan 31 '17 23:01 polqf