Ramotion / paper-onboarding

:octocat: PaperOnboarding is a material design UI slider. Swift UI library by @Ramotion
https://www.ramotion.com/agency/app-development/
MIT License
3.33k stars 337 forks source link

Transparent background #51

Closed nauynix closed 5 years ago

nauynix commented 7 years ago

I want to have my own background in an image view. However, changing the alpha of the background colour to 0 in onboardingiteminfo seems to set it to white instead.

alkanyunus commented 6 years ago

Hi, you can implement 'onboardingConfigurationItem' delegate method, and adding custom views to item at index.

You can have it like below.

func onboardingConfigurationItem(_ item: OnboardingContentViewItem, index: Int) {
        // add custom background image
        let tmp: Int = 500

        // assume you have an array of uiimages
        if item.viewWithTag(tmp + 1) == nil {
            let imgView = UIImageView(image: backgroundImages[index])
            imgView.tag = tmp + 1
            imgView.contentMode = .scaleAspectFill

            item.insertSubview(imgView, at: 0)

            // for instance I like to have blur effect on my background images
            let blurEffect = UIBlurEffect(style: .dark)
            let blurOverlay = UIVisualEffectView(effect: blurEffect)
            blurOverlay.alpha = 0.90
            blurOverlay.frame = view.bounds
            blurOverlay.autoresizingMask = [.flexibleWidth, .flexibleHeight]

            imgView.addSubview(blurOverlay)

            // I use SnapKit for auyolayout engine
            // you can use whatever you want
            // important thing is you must give full screen size as imageview frame size.
            imgView.snp.remakeConstraints({ (make) in
                make.size.equalTo(view.bounds.size)
            })

            blurOverlay.snp.remakeConstraints({ (make) in
                make.edges.equalToSuperview()
            })
        }
}
rhjordaan commented 4 years ago

how could you make the imageview the full frame size without having to import snapkit?