Skip to content

Commit 0076190

Browse files
committed
Updated to version 1.4.5
1 parent 1b2d51e commit 0076190

File tree

6 files changed

+35
-25
lines changed

6 files changed

+35
-25
lines changed

Example/THLabelExample/Main.storyboard

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<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">
2+
<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">
33
<dependencies>
44
<deployment identifier="iOS"/>
55
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6244"/>

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
THLabel
22

3-
Version 1.4.4, September 23rd, 2014
3+
Version 1.4.5, November 12th, 2014
44

55
Copyright (c) 2014 Tobias Hagemann, tobiha.de
66

README.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ THLabel is a subclass of UILabel, which additionally allows shadow blur, inner s
1313

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

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

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

2424
## Usage
2525

26-
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.
26+
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.
2727

2828
## Properties
2929

3030
``` objective-c
31-
@property (nonatomic, assign) CGFloat letterSpacing;
31+
@property (nonatomic, assign) IBInspectable CGFloat letterSpacing;
32+
@property (nonatomic, assign) IBInspectable CGFloat lineSpacing;
3233
```
3334

34-
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.
35+
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.
36+
37+
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.
3538

3639
``` objective-c
37-
@property (nonatomic, assign) CGFloat shadowBlur;
40+
@property (nonatomic, assign) IBInspectable CGFloat shadowBlur;
3841
```
3942

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

4245
``` objective-c
43-
@property (nonatomic, assign) CGFloat innerShadowBlur;
44-
@property (nonatomic, assign) CGSize innerShadowOffset;
45-
@property (nonatomic, strong) UIColor *innerShadowColor;
46+
@property (nonatomic, assign) IBInspectable CGFloat innerShadowBlur;
47+
@property (nonatomic, assign) IBInspectable CGSize innerShadowOffset;
48+
@property (nonatomic, strong) IBInspectable UIColor *innerShadowColor;
4649
```
4750

4851
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.
4952

5053
``` objective-c
51-
@property (nonatomic, assign) CGFloat strokeSize;
52-
@property (nonatomic, strong) UIColor *strokeColor;
54+
@property (nonatomic, assign) IBInspectable CGFloat strokeSize;
55+
@property (nonatomic, strong) IBInspectable UIColor *strokeColor;
5356
@property (nonatomic, assign) THLabelStrokePosition strokePosition;
5457
```
5558

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

5861
``` objective-c
59-
@property (nonatomic, strong) UIColor *gradientStartColor;
60-
@property (nonatomic, strong) UIColor *gradientEndColor;
62+
@property (nonatomic, strong) IBInspectable UIColor *gradientStartColor;
63+
@property (nonatomic, strong) IBInspectable UIColor *gradientEndColor;
6164
@property (nonatomic, copy) NSArray *gradientColors;
62-
```
63-
64-
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.
65-
66-
``` objective-c
6765
@property (nonatomic, assign) CGPoint gradientStartPoint;
6866
@property (nonatomic, assign) CGPoint gradientEndPoint;
6967
```
7068

69+
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.
70+
7171
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).
7272

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

7979
``` objective-c
8080
@property (nonatomic, assign) UIEdgeInsets textInsets;
81-
@property (nonatomic, assign) BOOL automaticallyAdjustTextInsets;
81+
@property (nonatomic, assign) IBInspectable BOOL automaticallyAdjustTextInsets;
8282
```
8383

8484
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.

RELEASE NOTES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Version 1.4.5
2+
3+
- Added support for IB_DESIGNABLE and IBInspectable, only available with Xcode 6.
4+
- Added lineSpacing property.
5+
16
Version 1.4.4
27

38
- Fixed memory leak.

THLabel/THLabel.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// THLabel.h
33
//
4-
// Version 1.4.4
4+
// Version 1.4.5
55
//
66
// Created by Tobias Hagemann on 11/25/12.
77
// Copyright (c) 2014 tobiha.de. All rights reserved.
@@ -42,7 +42,6 @@
4242
// 3. This notice may not be removed or altered from any source distribution.
4343
//
4444

45-
#import <UIKit/UIKit.h>
4645

4746
#ifndef IB_DESIGNABLE
4847
#define IB_DESIGNABLE
@@ -51,6 +50,9 @@
5150
#define IBInspectable
5251
#endif
5352

53+
54+
#import <UIKit/UIKit.h>
55+
5456
typedef NS_ENUM(NSInteger, THLabelStrokePosition) {
5557
THLabelStrokePositionOutside,
5658
THLabelStrokePositionCenter,
@@ -68,6 +70,7 @@ IB_DESIGNABLE
6870
@interface THLabel : UILabel
6971

7072
@property (nonatomic, assign) IBInspectable CGFloat letterSpacing;
73+
@property (nonatomic, assign) IBInspectable CGFloat lineSpacing;
7174

7275
@property (nonatomic, assign) IBInspectable CGFloat shadowBlur;
7376

THLabel/THLabel.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// THLabel.m
33
//
4-
// Version 1.4.4
4+
// Version 1.4.5
55
//
66
// Created by Tobias Hagemann on 11/25/12.
77
// Copyright (c) 2014 tobiha.de. All rights reserved.
@@ -453,11 +453,13 @@ - (CTFrameRef)frameRefFromSize:(CGSize)size textRectOutput:(CGRect *)textRectOut
453453
CTFontRef fontRef = CTFontCreateWithName((__bridge CFStringRef)self.font.fontName, self.font.pointSize, NULL);
454454
CTTextAlignment alignment = NSTextAlignmentToCTTextAlignment ? NSTextAlignmentToCTTextAlignment(self.textAlignment) : [self CTTextAlignmentFromNSTextAlignment:self.textAlignment];
455455
CTLineBreakMode lineBreakMode = (CTLineBreakMode)self.lineBreakMode;
456+
CGFloat lineSpacing = self.lineSpacing;
456457
CTParagraphStyleSetting paragraphStyleSettings[] = {
457458
{kCTParagraphStyleSpecifierAlignment, sizeof(CTTextAlignment), &alignment},
458-
{kCTParagraphStyleSpecifierLineBreakMode, sizeof(CTLineBreakMode), &lineBreakMode}
459+
{kCTParagraphStyleSpecifierLineBreakMode, sizeof(CTLineBreakMode), &lineBreakMode},
460+
{kCTParagraphStyleSpecifierLineSpacingAdjustment, sizeof(CGFloat), &lineSpacing}
459461
};
460-
CTParagraphStyleRef paragraphStyleRef = CTParagraphStyleCreate(paragraphStyleSettings, 2);
462+
CTParagraphStyleRef paragraphStyleRef = CTParagraphStyleCreate(paragraphStyleSettings, 3);
461463
CFNumberRef kernRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberCGFloatType, &_letterSpacing);
462464

463465
// Set up attributed string.

0 commit comments

Comments
 (0)