Skip to content

Commit 2d90e0a

Browse files
authored
Update README.markdown
1 parent 2c5991d commit 2d90e0a

File tree

1 file changed

+43
-12
lines changed

1 file changed

+43
-12
lines changed

README.markdown

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,55 @@ TDBadgedCell grew out of the need for TableViewCell badges and the lack of them
1212
<img src="http://up.tmdvs.me/j2a9/d" width="432">&nbsp;
1313
<img src="http://up.tmdvs.me/j23l/d" width="432">
1414

15-
To set the content of your badge (String) simply do:
15+
## Usage and examples
16+
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:
1617

17-
```Swift
18-
cell.badgeString = "Hello, World!"
18+
```swift
19+
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
20+
var cell = tableView.dequeueReusableCell(withIdentifier:"BadgedCell") as? TDBadgedCell;
21+
if(cell == nil) {
22+
cell = TDBadgedCell(style: .default, reuseIdentifier: "BadgedCell");
23+
}
24+
25+
// ...
26+
27+
return cell!
28+
}
1929
```
2030

21-
You can set _badgeColor_ and _badgeColorHighlighted_ to modify the colour of the badges:
31+
You can modify the badges appearance in a number of different ways.
2232

23-
```Swift
24-
cell.badgeColor = UIColor.orangeColor()
25-
```
33+
- ### Setting badge value
34+
To set the content of your badge (String) simply do:
2635

27-
You can also specify a border radius and font size for your badges:
36+
```Swift
37+
cell.badgeString = "Hello, World!"
38+
```
2839

29-
```Swift
30-
cell.badgeRadius = 9;
31-
cell.badgeFontSize = 18;
32-
```
40+
- ### Changing the badge color
41+
You can set _badgeColor_ and _badgeColorHighlighted_ to modify the colour of the badges:
42+
43+
```Swift
44+
cell.badgeColor = .orange
45+
cell.badgeColorHighlighted = .green
46+
```
47+
48+
- ### Setting the font size and text color
49+
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:
50+
51+
```Swift
52+
cell.badgeTextColor = .black;
53+
cell.badgeFontSize = 18;
54+
```
55+
56+
- ### Corner radius
57+
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:
58+
59+
```Swift
60+
cell.badgeRadius = 0;
61+
```
62+
63+
If you have any feedback or feature requests, simply [open an issue](https://github.com/tmdvs/TDBadgedCell/issues) on the TDBadgedCell github repo.
3364

3465
## Licence and that stuff
3566
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.

0 commit comments

Comments
 (0)