From 6f69fd955ea9d394207c574b962b008610931d8d Mon Sep 17 00:00:00 2001 From: Tobias Hagemann Date: Wed, 12 Nov 2014 18:26:01 +0100 Subject: [PATCH] Updated to version 1.4.5 --- Example/THLabelExample/Main.storyboard | 2 +- LICENSE.md | 2 +- README.md | 36 +++++++++++++------------- RELEASE NOTES.md | 5 ++++ THLabel.podspec | 2 +- THLabel/THLabel.h | 7 +++-- THLabel/THLabel.m | 8 +++--- 7 files changed, 36 insertions(+), 26 deletions(-) diff --git a/Example/THLabelExample/Main.storyboard b/Example/THLabelExample/Main.storyboard index 075b5cf..eee2b96 100644 --- a/Example/THLabelExample/Main.storyboard +++ b/Example/THLabelExample/Main.storyboard @@ -1,5 +1,5 @@ - + diff --git a/LICENSE.md b/LICENSE.md index cfdc166..286ad83 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -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 diff --git a/README.md b/README.md index 0343dee..6ee33ab 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 @@ -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. diff --git a/RELEASE NOTES.md b/RELEASE NOTES.md index 16eef62..e38fb2d 100644 --- a/RELEASE NOTES.md +++ b/RELEASE NOTES.md @@ -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. diff --git a/THLabel.podspec b/THLabel.podspec index 6c36c15..995923b 100644 --- a/THLabel.podspec +++ b/THLabel.podspec @@ -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' diff --git a/THLabel/THLabel.h b/THLabel/THLabel.h index 3774391..11ef6ad 100644 --- a/THLabel/THLabel.h +++ b/THLabel/THLabel.h @@ -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. @@ -42,7 +42,6 @@ // 3. This notice may not be removed or altered from any source distribution. // -#import #ifndef IB_DESIGNABLE #define IB_DESIGNABLE @@ -51,6 +50,9 @@ #define IBInspectable #endif + +#import + typedef NS_ENUM(NSInteger, THLabelStrokePosition) { THLabelStrokePositionOutside, THLabelStrokePositionCenter, @@ -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; diff --git a/THLabel/THLabel.m b/THLabel/THLabel.m index 77506d8..43bd881 100644 --- a/THLabel/THLabel.m +++ b/THLabel/THLabel.m @@ -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. @@ -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.