SkillAgentSearch skills...

ScratchCardView

A scratch card view for iOS

Install / Use

/learn @pgorzelany/ScratchCardView
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

ScratchCardView

Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

ScratchCardView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "ScratchCardView"

Documentation

Extensive documentation can be found Here.

Special thanks to the Jazzy project for automatic documentation generation.

Usage

See the example project for usage.

You can setup custom views for both the scratch card cover and the cratch card content. The setup is done through a delegate.

class YourViewController: UIViewController {
    ...
    override func viewDidLoad() {
        super.viewDidLoad()

        configureScratchCardView()
    }

    private func configureScratchCardView() {
        scratchCardView.delegate = self
        scratchCardView.scratchWidth = 150
    }
}

extension YourViewController: ScratchCardViewDelegate {

    func coverView(for scratchCardView: ScratchCardView) -> UIView {
        let coverView = UIView()
        coverView.backgroundColor = UIColor.gray
        return coverView
    }

    func contentView(for scratchCardView: ScratchCardView) -> UIView {
        let imageView = UIImageView(image: yourCustomImage)
        imageView.contentMode = .scaleAspectFill
        return imageView
    }
}

That is all you need to know, its that simple :)

If you want to reload the ScratchCardView call:

scratchCardView.reloadView()

This will trigger a call to your delegate for a new cover and content view.

Author

pgorzelany, piotr.gorzelany@gmail.com

License

ScratchCardView is available under the MIT license. See the LICENSE file for more info.

View on GitHub
GitHub Stars309
CategoryDevelopment
Updated5mo ago
Forks26

Languages

Swift

Security Score

92/100

Audited on Oct 20, 2025

No findings