Giter Site home page Giter Site logo

silvrwolfboy / tdbadgedcell Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tmdvs/tdbadgedcell

0.0 1.0 1.0 1.63 MB

TDBadgedCell is a table view cell class that adds a badge, similar to the badges in Apple's own apps

Home Page: www.tmdvs.me

License: MIT License

Swift 100.00%

tdbadgedcell's Introduction

TDBadgedCell

Version Carthage compatible Platform License Downloads

TDBadgedCell grew out of the need for TableViewCell badges and the lack of them in iOS (see the article explaining this on TUAW Engadget). Recently the project has been re-written in Swift and much simplified.

 

Usage and examples

TDBadgedCell is designed to be a drop in replacement to UITableViewCell with the added benifit of a simple badge on the right hand side of the cell, similar to those you'll find in Mail.app and Settings.app. All you need to do to implement TDBadgedCell is supply a TDBadgedCell instance in your cellForRowAt indexPath: method:

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  var cell = tableView.dequeueReusableCell(withIdentifier:"BadgedCell") as? TDBadgedCell;
  if(cell == nil) {
    cell = TDBadgedCell(style: .default, reuseIdentifier: "BadgedCell");
  }

  // ...
  
  return cell!
}

You can modify the badges appearance in a number of different ways.

  • Setting badge value

    To set the content of your badge (String) simply do:

    cell.badgeString = "Hello, World!"
  • Changing the badge color

    You can set badgeColor and badgeColorHighlighted to modify the colour of the badges:

    cell.badgeColor = .orange
    cell.badgeColorHighlighted = .green
  • Setting the font size and text color

    By default the badge text will be clipped out of the badge background allowing you to see through to the background colour beneath. However you can specify a text color manually along with the badges font size:

    cell.badgeTextColor = .black;
    cell.badgeFontSize = 18;
  • Corner radius

    You can modify the badges corner radius allowing you to change the badges shape from the default "pill" shape to a square or rounded rectangle:

    cell.badgeRadius = 0;
  • Badge Offset

    You can set the badge's offset from the right hand side of the Table View Cell

    cell.badgeOffset = CGPoint(x:10.0, y:0)
  • Badge Text Offset

    You can add an offset to the text within the badge

    cell.badgeTextOffset = 5.0

If you have any feedback or feature requests, simply open an issue on the TDBadgedCell github repo.

Licence and that stuff

TDBadgedCell is a free to use class for everyone. I wrote it so people could have the badges Apple never provided us with. If you modify the source please share alike and if you think you've improved upon what I have written I recommend sending me a pull request.

Please note: If you are using TDBadgedCell in your project please make sure you leave credit where credit is due. Chances are I won't notice if you haven't left credit but karma will…

tdbadgedcell's People

Contributors

tmdvs avatar coryallegory avatar julientherier avatar pierrephi avatar hanawat avatar jkubicek avatar mjwybrow avatar ryanmasondavies avatar xzenon avatar danielebogo avatar ahanmal avatar exalted avatar andruu avatar chris-babelbark avatar irvis avatar rogymd avatar jeffreyjackson avatar frisocki avatar tchaikov avatar markcleonard avatar nbonamy avatar 0xacdc avatar scottcc avatar t-pham avatar tonymillion avatar valeriomazzeo avatar fulldecent avatar emrcftci avatar kishikawakatsumi avatar vtourraine avatar

Watchers

 avatar

Forkers

personalhomeman

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.