TDBadgedCell 0,1,-2,0,1,0,3

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

TDBadgedCell

Version Platform License Downloads Apps

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

Note: You can find the old Objective-C version on the deprecated-objective-c branch.

 

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;

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…

Related Repositories

TDBadgedCell

TDBadgedCell

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

TDBadgedCell

TDBadgedCell

UITableViewCell subclass that adds a "badgeNumber" (int) property the cell. This badge draws in an identical manner to the badges present in MobileMail.app. The class supports custom badge colours for both normal and highlighted states. ...

TDBadgedCell

TDBadgedCell

UITableViewCell subclass that adds a "badgeString" property to table view cells. There is a branch for ARC supported version. ...


Top Contributors

tmdvs coryallegory julientherier pierrephi jkubicek mjwybrow iotize xzenon danielebogo irvis exalted andruu ahanmal ferambot RogyMD frisocki tchaikov markcleonard nbonamy T-Pham tonymillion valeriomazzeo kishikawakatsumi vtourraine

Releases

-   v3.1 zip tar
-   v3.0 zip tar
-   v2.6 zip tar
-   v2.5.2.1 zip tar
-   v2.5.2 zip tar
-   v2.5.1 zip tar
-   v2.5 zip tar
-   v2.4.2 zip tar
-   v2.4.1 zip tar
-   v2.4 zip tar
-   v2.3.2 zip tar
-   v2.3.1 zip tar
-   v2.3 zip tar
-   v2.2 zip tar
-   v2.1 zip tar
-   v2.0 zip tar
-   v1.3.1 zip tar
-   v1.3 zip tar
-   v1.2 zip tar
-   v1.1 zip tar
-   v1.0 zip tar
-   v0.9.7 zip tar
-   v0.9.6 zip tar
-   v0.9.5 zip tar
-   v0.9.4 zip tar
-   v0.9.3 zip tar
-   v0.9.2 zip tar
-   v0.9.1 zip tar
-   v0.9 zip tar
-   v0.6.5.1 zip tar