JaylenCoding / MCScratchImageView

A custom ImageView that is used to cover the surface of other view like a scratch card, user can swipe the mulch to see the view below.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Not working when Background view Dynamically

Kida007 opened this issue · comments

Hey @Minecodecraft thanks for the lib . Im new to swift , and try to run this lib through react-native.

Problem : the scratch action doesn't work as soon as i add backgroundView ( mainImageView) .

Here is my Example :

class ScratchCardView: UIView {
  
  
  override init(frame: CGRect){
    super.init(frame:frame)
       
    let mainImageView = UIImageView(image:UIImage(named:"pin.jpg"))
    
    mainImageView.frame = CGRect(x:0,y:0,width:300,height:300)

    
    var scratchImageView: MCScratchImageView!
    scratchImageView = MCScratchImageView(frame:CGRect(x:0,y:0,width:300,height:300))
    scratchImageView.setMaskImage(UIImage(named:"pin.jpg")!, spotRadius: 10)
    
    self.addSubview(mainImageView)
    self.addSubview(scratchImageView)
    

  }


}

as soon as I comment self.addSubview(mainImageView) it works !

sorry my bad , i used the same image xD , lol !!!!!!!!!