<commit_before># Overview

This is a badge view for iOS 7+ written in Swift. The style is similar to the springboard badges in iOS 7 or 8.
The badge is a subclass of UILabel view and can be customized from the Storyboard.

<img src='graphics/swift-badge.png' height='49' alt='Swift Badge'>
<img src='graphics/swift-badge-with-border.png' height='49' alt='Swift Badge with border'>

## Usage

Copy [SwiftBadge.swift](https://github.com/marketplacer/swift-badge/blob/master/swift-badge/SwiftBadge.swift) to your project.


### Creating a badge in Storyboard

* Drag a **Label** to your view.
* Set its `class` to `SwiftBadge` in identity inspector.

<img src='https://raw.githubusercontent.com/marketplacer/swift-badge/master/graphics/swift_badge_class_name_2.png' width='258' alt='Add badge to storyboard'>

* Set the badge properties in the attributes inspector.

<img src='https://raw.githubusercontent.com/marketplacer/swift-badge/master/graphics/swift_badge_attributes_inspector.png' width='376' alt='Change badge properties in attribute inspector'>


### Creating a badge from code

```Swift
let badge = SwiftBadge()
view.addSubview(badge)
```

## Customization

```Swift
// Text
badge.text = "2"

// Insets
badge.insets = CGSize(width: 12, height: 12)

// Font
badge.font = UIFont.preferredFontForTextStyle(UIFontTextStyleBody)

// Text color
badge.textColor = UIColor.yellowColor()<commit_msg>Add demo for creating badge from code<commit_after># Overview

This is a badge view for iOS 7+ written in Swift. The style is similar to the springboard badges in iOS 7 or 8.
The badge is a subclass of UILabel view and can be customized from the Storyboard.

<img src='graphics/swift-badge.png' height='49' alt='Swift Badge'>
<img src='graphics/swift-badge-with-border.png' height='49' alt='Swift Badge with border'>

## Usage

Copy [SwiftBadge.swift](https://github.com/marketplacer/swift-badge/blob/master/swift-badge/SwiftBadge.swift) to your project.


### Creating a badge in Storyboard

* Drag a **Label** to your view.
* Set its `class` to `SwiftBadge` in identity inspector.

<img src='https://raw.githubusercontent.com/marketplacer/swift-badge/master/graphics/swift_badge_class_name_2.png' width='258' alt='Add badge to storyboard'>

* Set the badge properties in the attributes inspector.

<img src='https://raw.githubusercontent.com/marketplacer/swift-badge/master/graphics/swift_badge_attributes_inspector.png' width='376' alt='Change badge properties in attribute inspector'>


### Creating a badge from code

See [demo app example](https://github.com/marketplacer/swift-badge/blob/master/swift-badge/CreateBadgeFromCodeViewController.swift).

```Swift
let badge = SwiftBadge()
view.addSubview(badge)
```

## Customization

```Swift
// Text
badge.text = "2"

// Insets
badge.insets = CGSize(width: 12, height: 12)

// Font
badge.font = UIFont.preferredFontForTextStyle(UIFontTextStyleBody)

// Text color
badge.textColor = UIColor.yellowColor()
{'fraction_non_alphanumeric': 0.12178619756427606, 'fraction_numerical': 0.012855209742895805, 'mean_word_length': 5.122153209109731, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 7, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1706778', 'n_tokens_mistral': 1055, 'n_tokens_neox': 937, 'n_words': 269}