Latest 0.0.2
Homepage https://github.com/tantalic/KLSDateLabel
License MIT
Platforms ios 5.0, requires ARC
Dependencies TTTLocalizedPluralString
Authors

A UILabel subclass for displaying dates. By default KLSDateLabel will use a relative description ("9 minutes ago", "16 hours from now", etc) for dates within 7 days of the current date (this behavior can be disabled). For dates outside of this range a date formatter is used to transform the date into text. The default date formatter uses a long date style and does not include the time.

Usage

Basic Usage

Instead of providing a NSString for the label text (as you would do with UILabel), KLSDateLabel uses a NSDate instance which is used to generate the label text:

KLSDateLabel *dateLabel = [[KLSDateLabel alloc] initWithFrame:CGRectMake(20, 20, 280, 40)];
dateLabel.date = [NSDate date];

Advanced Usage

The behavior of KLSDateLabel’s can be customized through the properties available. Please see the documentation for more information.

Documentation

When you install KLSDateLabel through CocoaPods, documentation will be installed into Xcode’s documentation viewer. The documentation is also available online online at CocoaDocs. If you are not using CocoaPods you can manually install the documentation by installing appledoc and running the following command:

$ appledoc -p KLSDateLabel -c "Keivn Stock" --company-id com.tantalic KLSDateLabel/*.h

Installation

The recommended way to use KLSDateLabel is with the CocoaPods dependency manager.

  1. Install CocoaPods (if not already installed)

  2. Create a Podfile for your project in the same directory as your Xcode project file:

    $ touch Podfile
  3. Add the following line to your Podfile

    pod 'KLSDateLabel', '~> 0.0'
  4. Update (or create) :

    $ pod install
  5. Always open the Xcode workspace (.xcworkspace) instead of the project file to work on your project

Requirements

If you choose to use the source files directly you are responsible for meeting the following requirements.

iOS 5.0 or Greater

KLSDateLabel has only been tested on iOS 5.0 and greater. It may work with previous releases but is not recomended.

Automatic Reference Counting (ARC)

KLSDateLabel requires ARC. To use KLSDateLabel in a non-arc project, you will need to set a -fobjc-arc compiler flag on KLSDateLabel.m. To set this compiler flag in Xcode, go to your active target and select the "Build Phases" tab. Expand the "Compile Sources" phase and double click on the KLSDateLabel.m file. Insert -fobjc-arc and click "Done".

TTTLocalizedPluralString

KLSDateLabel uses TTTLocalizedPluralString for handling localization strings. The TTTLocalizedPluralString macros work simular to the NSLocalizedString macros but add a count argument.

License

KLSDateLabel is made available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "KLSDateLabel",
    "version": "0.0.2",
    "summary": "A UILabel subclass for displaying dates.",
    "homepage": "https://github.com/tantalic/KLSDateLabel",
    "license": "MIT",
    "authors": {
        "Kevin L. Stock": "[email protected]"
    },
    "source": {
        "git": "https://github.com/tantalic/KLSDateLabel.git",
        "tag": "0.0.2"
    },
    "platforms": {
        "ios": "5.0"
    },
    "source_files": "KLSDateLabel/*.{h,m}",
    "public_header_files": "KLSDateLabel/*.h",
    "resources": "KLSDateLabel/*.bundle",
    "requires_arc": true,
    "dependencies": {
        "TTTLocalizedPluralString": [
            "~> 0.0.4"
        ]
    }
}

Pin It on Pinterest

Share This