You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// use default touch point radius
scratchImageView.setMaskImage(yourUIImage)
// use custom touch point radius
scratchImageView.setMaskImage(yourUIImage, spotRadius:100)
Implement the delegate methods:
// set the delegate
scratchImageView.delegate =***
/* ... */
// implement the MCScratchImageViewDelegate method
extensionYourController:MCScratchImageViewDelegate{func mcScratchImageView(_ mcScratchImageView:MCScratchImageView, didChangeProgress progress:CGFloat){print("Progress did changed: "+ String(format:"%.2f", progress))if(progress >=0.8){
mcScratchImageView.scratchAll()}}}
API declaration
// current scratched progress
publicvarprogress:CGFloat
// Determin the radius of the touch point
private(set)varspotRadius:CGFloat=45.0
// set the mask image & radius
publicfunc setMaskImage(_ image:UIImage)
public func setMaskImage(_ image:UIImage, spotRadius:CGFloat)
// scratch all mask fields
public func scratchAll()
Example Project
In "Example" folder.
Tips
Don't set the scratchImageView.image directlly, you need to use setMaskImage(paras) to set the mask image.
Don't set the touch point radius (var spotRadius: CGFloat) directlly.