scr

ScratchCardView

A scratch card view for iOS

Showing:

Popularity

Downloads/wk

0

GitHub Stars

304

Maintenance

Last Commit

2yrs ago

Contributors

0

Package

Dependencies

0

License

MIT

Categories

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.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100