Skip to content

Commit

Permalink
Updated to version 1.4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
tobihagemann committed Nov 12, 2014
1 parent 1b2d51e commit 6f69fd9
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Example/THLabelExample/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6250" systemVersion="14A388a" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="456-qT-Q4o">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6250" systemVersion="14A389" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="456-qT-Q4o">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6244"/>
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
THLabel

Version 1.4.4, September 23rd, 2014
Version 1.4.5, November 12th, 2014

Copyright (c) 2014 Tobias Hagemann, tobiha.de

Expand Down
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ THLabel is a subclass of UILabel, which additionally allows shadow blur, inner s

The easiest way to use THLabel in your app is via [CocoaPods](http://cocoapods.org/ "CocoaPods").

1. Add the following line in the project's Podfile file: `pod 'THLabel', '~> 1.4.4'`
1. Add the following line in the project's Podfile file: `pod 'THLabel', '~> 1.4.5'`
2. Run the command `pod install` from the Podfile folder directory.

### Manual Installation
Expand All @@ -23,51 +23,51 @@ The easiest way to use THLabel in your app is via [CocoaPods](http://cocoapods.o

## Usage

You can create THLabels programmatically, or create them in Interface Builder by dragging an ordinary UILabel into your view and setting its *Custom Class* to THLabel.
You can create THLabels programmatically, or create them in Interface Builder by dragging an ordinary UILabel into your view and setting its *Custom Class* to THLabel. With Xcode 6 you can set most of the properties within Interface Builder, which will preview your changes immediately.

## Properties

``` objective-c
@property (nonatomic, assign) CGFloat letterSpacing;
@property (nonatomic, assign) IBInspectable CGFloat letterSpacing;
@property (nonatomic, assign) IBInspectable CGFloat lineSpacing;
```

You can modify the letter spacing of the text (also known as kerning) by changing the `letterSpacing` property. The default value is `0.0`. A positive value will separate the characters, whereas a negative value will make them closer.
You can modify letter spacing of the text (also known as kerning) by changing the `letterSpacing` property. The default value is `0.0`. A positive value will separate the characters, whereas a negative value will make them closer.

Modify line spacing of the text (also known as leading) by changing the `lineSpacing` property. The default value is `0.0`. Only positive values will have an effect.

``` objective-c
@property (nonatomic, assign) CGFloat shadowBlur;
@property (nonatomic, assign) IBInspectable CGFloat shadowBlur;
```

Additionally to UILabel's `shadowColor` and `shadowOffset`, you can set a shadow blur to soften the shadow.

``` objective-c
@property (nonatomic, assign) CGFloat innerShadowBlur;
@property (nonatomic, assign) CGSize innerShadowOffset;
@property (nonatomic, strong) UIColor *innerShadowColor;
@property (nonatomic, assign) IBInspectable CGFloat innerShadowBlur;
@property (nonatomic, assign) IBInspectable CGSize innerShadowOffset;
@property (nonatomic, strong) IBInspectable UIColor *innerShadowColor;
```

The inner shadow has similar properties as UILabel's shadow, once again additionally with a shadow blur. If an inner shadow and a stroke are overlapping, it will appear beneath the stroke.

``` objective-c
@property (nonatomic, assign) CGFloat strokeSize;
@property (nonatomic, strong) UIColor *strokeColor;
@property (nonatomic, assign) IBInspectable CGFloat strokeSize;
@property (nonatomic, strong) IBInspectable UIColor *strokeColor;
@property (nonatomic, assign) THLabelStrokePosition strokePosition;
```

You can set an outer, centered or inner stroke by setting the `strokePosition` property. Default value is `THLabelStrokePositionOutside`. Other options are `THLabelStrokePositionCenter` and `THLabelStrokePositionInside`.

``` objective-c
@property (nonatomic, strong) UIColor *gradientStartColor;
@property (nonatomic, strong) UIColor *gradientEndColor;
@property (nonatomic, strong) IBInspectable UIColor *gradientStartColor;
@property (nonatomic, strong) IBInspectable UIColor *gradientEndColor;
@property (nonatomic, copy) NSArray *gradientColors;
```

The gradient can consist of multiple colors, which have to be saved as UIColor objects in the `gradientColors` array. For more convenience, `gradientStartColor` and `gradientEndColor` will fill up the array accordingly.

``` objective-c
@property (nonatomic, assign) CGPoint gradientStartPoint;
@property (nonatomic, assign) CGPoint gradientEndPoint;
```

The gradient can consist of multiple colors, which have to be saved as UIColor objects in the `gradientColors` array. For more convenience, `gradientStartColor` and `gradientEndColor` will fill up the array accordingly.

The starting and ending points of the gradient are in the range 0 to 1, where (0, 0) is the top-left and (1, 1) the bottom-right of the text. The default value for `gradientStartPoint` is (0.5, 0.2) and for `gradientEndPoint` it is (0.5, 0.8).

``` objective-c
Expand All @@ -78,7 +78,7 @@ You can fade in/out your label by setting the `fadeTruncatingMode` property. Def

``` objective-c
@property (nonatomic, assign) UIEdgeInsets textInsets;
@property (nonatomic, assign) BOOL automaticallyAdjustTextInsets;
@property (nonatomic, assign) IBInspectable BOOL automaticallyAdjustTextInsets;
```

Effects like stroke and shadow can't be drawn outside of the bounds of the label view. You may need to set text insets to move a bit away from the edge so that the effects don't get clipped. This will be automatically done if you set `automaticallyAdjustTextInsets` to YES, which is also the default value.
Expand Down
5 changes: 5 additions & 0 deletions RELEASE NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Version 1.4.5

- Added support for IB_DESIGNABLE and IBInspectable, only available with Xcode 6.
- Added lineSpacing property.

Version 1.4.4

- Fixed memory leak.
Expand Down
2 changes: 1 addition & 1 deletion THLabel.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'THLabel'
s.version = '1.4.4'
s.version = '1.4.5'
s.summary = 'THLabel is a subclass of UILabel, which additionally allows shadow blur, inner shadow, stroke text and fill gradient.'
s.homepage = 'https://github.com/MuscleRumble/THLabel'
s.screenshots = 'https://raw.githubusercontent.com/MuscleRumble/THLabel/master/screenshot.png'
Expand Down
7 changes: 5 additions & 2 deletions THLabel/THLabel.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// THLabel.h
//
// Version 1.4.4
// Version 1.4.5
//
// Created by Tobias Hagemann on 11/25/12.
// Copyright (c) 2014 tobiha.de. All rights reserved.
Expand Down Expand Up @@ -42,7 +42,6 @@
// 3. This notice may not be removed or altered from any source distribution.
//

#import <UIKit/UIKit.h>

#ifndef IB_DESIGNABLE
#define IB_DESIGNABLE
Expand All @@ -51,6 +50,9 @@
#define IBInspectable
#endif


#import <UIKit/UIKit.h>

typedef NS_ENUM(NSInteger, THLabelStrokePosition) {
THLabelStrokePositionOutside,
THLabelStrokePositionCenter,
Expand All @@ -68,6 +70,7 @@ IB_DESIGNABLE
@interface THLabel : UILabel

@property (nonatomic, assign) IBInspectable CGFloat letterSpacing;
@property (nonatomic, assign) IBInspectable CGFloat lineSpacing;

@property (nonatomic, assign) IBInspectable CGFloat shadowBlur;

Expand Down
8 changes: 5 additions & 3 deletions THLabel/THLabel.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// THLabel.m
//
// Version 1.4.4
// Version 1.4.5
//
// Created by Tobias Hagemann on 11/25/12.
// Copyright (c) 2014 tobiha.de. All rights reserved.
Expand Down Expand Up @@ -453,11 +453,13 @@ - (CTFrameRef)frameRefFromSize:(CGSize)size textRectOutput:(CGRect *)textRectOut
CTFontRef fontRef = CTFontCreateWithName((__bridge CFStringRef)self.font.fontName, self.font.pointSize, NULL);
CTTextAlignment alignment = NSTextAlignmentToCTTextAlignment ? NSTextAlignmentToCTTextAlignment(self.textAlignment) : [self CTTextAlignmentFromNSTextAlignment:self.textAlignment];
CTLineBreakMode lineBreakMode = (CTLineBreakMode)self.lineBreakMode;
CGFloat lineSpacing = self.lineSpacing;
CTParagraphStyleSetting paragraphStyleSettings[] = {
{kCTParagraphStyleSpecifierAlignment, sizeof(CTTextAlignment), &alignment},
{kCTParagraphStyleSpecifierLineBreakMode, sizeof(CTLineBreakMode), &lineBreakMode}
{kCTParagraphStyleSpecifierLineBreakMode, sizeof(CTLineBreakMode), &lineBreakMode},
{kCTParagraphStyleSpecifierLineSpacingAdjustment, sizeof(CGFloat), &lineSpacing}
};
CTParagraphStyleRef paragraphStyleRef = CTParagraphStyleCreate(paragraphStyleSettings, 2);
CTParagraphStyleRef paragraphStyleRef = CTParagraphStyleCreate(paragraphStyleSettings, 3);
CFNumberRef kernRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberCGFloatType, &_letterSpacing);

// Set up attributed string.
Expand Down

0 comments on commit 6f69fd9

Please sign in to comment.