Skip to content

tolgahan-arikan/CountdownView

Repository files navigation

CountdownView

CocoaPods Compatible

Preview

Installation

Disclaimer note that came after 3 years: I would not suggest to actually use this. It was mostly a learning experience. In case you are trying to build something similar and trying to find a starting point, I would advise just checking the animation implementation part.

If you want to use it anyway, you can just add the CountdownView folder to your project.

Usage

  1. use the basic show method or the one with completion block and automatic hiding
CountdownView.show(countdownFrom: Double, spin: Bool, animation: Animation)
CountdownView.show(countdownFrom: Double, spin: Bool, animation: Animation, autoHide: Bool, completion: (()->())?)
  1. hide if you didn't use auto hiding
CountdownView.hide(animation: Animation, options: (duration: Double, delay: Double), completion: (()->())?)

Animation options

  • fadeIn
  • fadeOut
  • fadeInLeft
  • fadeInRight
  • fadeOutLeft
  • fadeOutRight
  • zoomIn
  • zoomOut

Customizing

You can access the properties below from CountdownView's shared instance before you call the show function as you can see in the example and customize it any way you like and need.

Example

CountdownView.shared.frameSize = CGSize(width: 200.0, height: 200.0)

CountdownView.shared.backgroundViewColor = UIColor.cyan

CountdownView.shared.dismissStyle = .byTapOnOutside
 
CountdownView.show(countdownFrom: Double, spin: Bool, animation: Animation)

All properties

public var dismissStyle: DismissStyle
public var dismissStyleAnimation: Animation

public var frameSize: CGSize
public var framePosition: CGPoint

public var backgroundViewColor: UIColor

public var counterViewBackgroundColor: UIColor
public var counterViewShadowColor: UIColor
public var counterViewShadowRadius: CGFloat
public var counterViewShadowOpacity: Float

public var spinnerLineWidth: CGFloat
public var spinnerInset: CGFloat
public var spinnerStartColor: UIColor
public var spinnerEndColor: UIColor
public var colorTransition: Bool 

public var counterLabelFont: UIFont
public var counterLabelTextColor: UIColor

public var counterSubLabelText: String
public var counterSubLabelFont: UIFont
public var counterSubLabelTextColor: UIColor  

public var closeButtonTitleLabelText: String
public var closeButtonTitleLabelFont: UIFont
public var closeButtonTitleLabelColor: UIColor
public var closeButtonTopAnchorConstant: CGFloat
public var closeButtonLeftAnchorConstant: CGFloat
public var closeButtonImage: UIImage
public var closeButtonTintColor: UIColor

Requirements

  • iOS 9.0+
  • Swift 3+

License

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