Skip to content
I loved the way payments app's like Google pay and PhonePe used scratch card option to reward it's user. Hence with πŸ’› cloned the same scratch card effect for you guys out there
Swift Ruby
Branch: master
Clone or download
gokul g
gokul g Resized size
Latest commit 5e1cf1e Oct 2, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Example Changed init method Sep 6, 2019
GLScratchCard Changed init method Sep 6, 2019
ScreenShots Resized size Oct 2, 2019
.gitignore Initial commit Aug 15, 2019
.travis.yml Initial commit Aug 15, 2019
GLScratchCard.podspec Pod spec update Sep 6, 2019
LICENSE Removed files on wrong directory Aug 28, 2019
README.md Read me updated gif's added Oct 2, 2019
_Pods.xcodeproj Initial commit Aug 15, 2019

README.md

GLScratchCard

CI Status

Version

License

Platform

overView

Example

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

Requirements

GLScratchCard XCode 10 and Swift 4.2. With deployment target 11.0.

Installation

Cocoapods

GLScratchCard is available through CocoaPods. To install

it, simply add the following line to your Podfile:

pod 'GLScratchCard'

Manual

Copy the files from ~/Pods/DevelopmentPods/GLScratchCard/ to your project.

User Guide

Basic Usage

let controller = GLScratchCardController() controller.scratchCardView.addDelegate(delegate: self) controller.scratchCardView.bottomLayerView = UIImageView(image: UIImage(named: "cash_back")) controller.scratchCardView.topLayerImage = UIImage(named:"scratch_image")! controller.presentScratchController()

sampleGifDPay

Break Down

let controller = GLScratchCardController()

Setting up Components

Titles to be shown initilly, before scratch starts

controller.scratchCardView.doneButtonTitle = "Gift to a friend" controller.scratchCardView.scratchCardTitle = "Earn up to β‚Ή1,0000" controller.scratchCardView.scratchCardSubTitle = "From Google Pay \nEarned for paying \nGokul"

Title to be show after scratch ends,

controller.scratchCardView.afterScratchDoneButtonTitle = "Done" controller.scratchCardView.afterScratchTitle = "Woohoo!" controller.scratchCardView.afterScratchSubTitle = "Expect payment within a weak."

Top layer image view,

controller.scratchCardView.topLayerImage = UIImage(named:"scratch_image")!

Bottom layer image view (one that will be reviled after scratching ends),

controller.scratchCardView.bottomLayerView = UIImageView(image: UIImage(named: "cash_back"))

Can customise scratch size and shape (.round, .square, .butt),

controller.scratchCardView.scratchCardImageView.lineWidth = 50 controller.scratchCardView.scratchCardImageView.lineType = .round

Delegates

  1. GLScratchCardDelegate
  2. GLScratchCarImageViewDelegate

Add delegates,

controller.scratchCardView.addDelegate(delegate: self) controller.scratchCardView.scratchCardImageView.addDelegate(delegate:self)

GLScratchCardDelegate

func didCloseButtonPressed(sender: UIButton) func didDoneButtonPressed(sender: UIButton)

GLScratchCarImageViewDelegate

func scratchpercentageDidChange(value: Float) func didScratchStarted() func didScratchEnded()

sampleGifDPay

Author

Gokul, gokulece26@gmail.com

Social

License

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

You can’t perform that action at this time.