Coder Social home page Coder Social logo

volleyz / etbadge Goto Github PK

View Code? Open in Web Editor NEW
19.0 2.0 2.0 397 KB

A tool of swift to add or clear badge for any UIView。You can use it easily, also can custom it.

License: MIT License

Swift 96.31% Ruby 3.69%
badge etbadge uiview swift swift3 reddot new

etbadge's Introduction

ETBadge

A tool of swift to add or clear badge for any UIView。You can use it easily, also can custom it.

demo

Installation

The preferred way of installation is via CocoaPods. Just add

pod 'ETBadge'

and run pod install. It will install the most recent version of ETBadge.

Usage

  1. Add the following import to the top of the file:

import ETBadge

  1. Use the following to display badge easily:

badgeView.showBadge(withStyle: .redDot, value: 1, aniType: .none)

badgeView.showBadge(withStyle: .new, value: 1, aniType: .breathe)

badgeView.showBadge(withStyle: .number, value: 1, aniType: .scale)

or simply call interface: badgeView.showBadge()

  1. Use the following to hide badge easily:

badgeView.clearBadge();

4.Use the following to resume badge when it has been hidden:

badgeView.resumeBadge();


BADGE CUSTOMIZATION

Feel free to customize badge size, position, animation style or anything else.

ETBadge provides easy way to customize its style.:

public struct ETBadgeConfigure {
  var badgeFont: UIFont = UIFont.boldSystemFont(ofSize: 10)
  var badgeBgColor: UIColor = UIColor.red
  var badgeTextColor: UIColor = UIColor.white
  var aniType: ETBadgeAnimType = .none
  var badgeCenterOffset: CGPoint = CGPoint.zero
  var badgeStyle: ETBadgeStyle = .redDot
  var badgeMaximumBadgeNumber: Int = 99
  var badgeRedDotWidth: CGFloat = 8
  var badgeTextMargin: CGFloat = 6
  var badgeBounds: CGSize = CGSize(width: 16, height: 16)
}

You can customize style which you like.Simple used:

badgeView.badgeConfig.badgeBgColor = UIColor.yellow

Requirements

  • iOS 8.0+
  • Xcode 8.1+
  • Swift 3.0+


LICENSE

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

etbadge's People

Contributors

volleyz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

mrxmo pondkemon

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.