HNScratch is an ObjectiveC framework that makes it easier to make scratchable views and it works both in ObjectiveC or Swift projects.
To run the example project, clone the repo, and run pod install
from the Example directory first.
- iOS 14.5+
- Swift 5 or Objective-C
HNScratch is available through CocoaPods. To install it you can run the following line on terminal:
sudo gem install cocoapods
After that, you will need a Podfile in your project. Go to your project directory and run:
pod init
Add HNScratch to your project dependencies by simply adding the following line to your Podfile:
pod 'HNScratch'
At last, run:
pod install
Important things
HNScratch
is the class that you are going to usebackgroundImage
is theUIImage
that you want to show when you scratch the viewscratchableImage
is theUIImage
that you want to be scratchedlineWidth
is theCGFloat
size of the scratch
Creating instances
- Swift
let scratch = HNScratch(imagesAndWidth: backgroundImage, scratch: scratchableImage, lineWidth: lineWidth)
- Objective-C
HNScratch *scratch = [HNScratch.new initWithImagesAndWidth:backgroundImage scratchImage:scratchableImage lineWidth: lineWidth];
Setting-up the scratchView
- Swift
let scratchView = scratch?.getScratch()
- Objective-C
UIView *scratchView = [scratch getScratch];
Now you can use the scratchView
as you want.
- Hiago Chagas - hiagochagas
- Nathália Moura - nathaliacm
HNScratch is available under the MIT license. See the LICENSE file for more info.