Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow duplicate cutout in cell #8

Open
teonicel opened this issue Apr 20, 2018 · 2 comments
Open

allow duplicate cutout in cell #8

teonicel opened this issue Apr 20, 2018 · 2 comments

Comments

@teonicel
Copy link

teonicel commented Apr 20, 2018

Hi i encountered an issue with the library unfortunately it allows you add multiple cutouts to cell which creates an visual bug by taking the previous cutout into the draw function the solution is below

fileprivate func addCutoutView()
    {
        
        
        var hasCutout: Bool = false
        
        for view in self.subviews {
            if !(view is CutoutView) {
                view.alpha = 0
            } else {
                hasCutout = true
            }
        }
        if !hasCutout {
            let cutout = CutoutView()
            cutout.frame = self.bounds
            cutout.backgroundColor = UIColor.clear
            
            self.addSubview(cutout)
            cutout.setNeedsDisplay()
            cutout.boundInside(self)
            self.ld_setCutoutView(cutout)
        }
        
        
    }
@teonicel
Copy link
Author

teonicel commented Apr 20, 2018

Also an similar issue with visual deffect modified working code below

fileprivate func ld_addLoader()
    {
        if self.ld_getCutoutView() == nil {
            let gradient: CAGradientLayer = CAGradientLayer()
            gradient.frame = CGRect(x: 0, y: 0, width: self.bounds.size.width , height: self.bounds.size.height)
            self.layer.insertSublayer(gradient, at:0)
            self.configureAndAddAnimationToGradient(gradient)
        }
        
        self.addCutoutView()
    }

@malkouz
Copy link
Owner

malkouz commented Apr 23, 2018

please fork the library, then put your updates, then make a pull request.

I will be happy to accept your changes 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants