Skip to content

Commit

Permalink
Updated to version 1.4.7
Browse files Browse the repository at this point in the history
  • Loading branch information
tobihagemann committed Nov 26, 2015
1 parent 1517cb5 commit ba33b43
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 34 deletions.
5 changes: 4 additions & 1 deletion Example/THLabelExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
74338E5416830723001B12C9 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0450;
LastUpgradeCheck = 0700;
ORGANIZATIONNAME = tobiha.de;
};
buildConfigurationList = 74338E5716830723001B12C9 /* Build configuration list for PBXProject "THLabelExample" */;
Expand Down Expand Up @@ -223,6 +223,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
Expand Down Expand Up @@ -272,6 +273,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "THLabelExample/THLabelExample-Prefix.pch";
INFOPLIST_FILE = "THLabelExample/THLabelExample-Info.plist";
PRODUCT_BUNDLE_IDENTIFIER = "de.tobiha.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
Expand All @@ -285,6 +287,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "THLabelExample/THLabelExample-Prefix.pch";
INFOPLIST_FILE = "THLabelExample/THLabelExample-Info.plist";
PRODUCT_BUNDLE_IDENTIFIER = "de.tobiha.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
Expand Down
6 changes: 1 addition & 5 deletions Example/THLabelExample/THLabelExample-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIcons</key>
<dict/>
<key>CFBundleIcons~ipad</key>
<dict/>
<key>CFBundleIdentifier</key>
<string>de.tobiha.${PRODUCT_NAME:rfc1034identifier}</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
4 changes: 2 additions & 2 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
THLabel

Version 1.4.6, December 14th, 2014
Version 1.4.7, November 26th, 2015

Copyright (c) 2014 Tobias Hagemann, tobiha.de
Copyright (c) 2015 Tobias Hagemann, tobiha.de

This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
Expand Down
48 changes: 27 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,80 +13,86 @@ 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.6'`
1. Add the following line in the project's Podfile file: `pod 'THLabel', '~> 1.4'`
2. Run the command `pod install` from the Podfile folder directory.

### Manual Installation

1. Add `CoreText.framework` to your *Link Binary with Libraries* list.
2. Drag these files into your project: `THLabel.h`, `THLabel.m`

## IBDesignable / IBInspectable

There is an `ibdesignable` branch, if you're interested in this feature. It has been removed from the `master` branch, because IBDesignable and IBInspectable cause problems with CocoaPods, if you're not using `use_frameworks!` in your Podfile.

## 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. 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) IBInspectable CGFloat letterSpacing;
@property (nonatomic, assign) IBInspectable CGFloat lineSpacing;
@property CGFloat letterSpacing;
@property CGFloat lineSpacing;
```

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) IBInspectable CGFloat shadowBlur;
@property CGFloat shadowBlur;
```

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

``` objective-c
@property (nonatomic, assign) IBInspectable CGFloat innerShadowBlur;
@property (nonatomic, assign) IBInspectable CGSize innerShadowOffset;
@property (nonatomic, strong) IBInspectable UIColor *innerShadowColor;
@property CGFloat innerShadowBlur;
@property CGSize innerShadowOffset;
@property 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) IBInspectable CGFloat strokeSize;
@property (nonatomic, strong) IBInspectable UIColor *strokeColor;
@property (nonatomic, assign) THLabelStrokePosition strokePosition;
@property CGFloat strokeSize;
@property UIColor *strokeColor;
@property 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) IBInspectable UIColor *gradientStartColor;
@property (nonatomic, strong) IBInspectable UIColor *gradientEndColor;
@property (nonatomic, copy) NSArray *gradientColors;
@property (nonatomic, assign) CGPoint gradientStartPoint;
@property (nonatomic, assign) CGPoint gradientEndPoint;
@property UIColor *gradientStartColor;
@property UIColor *gradientEndColor;
@property NSArray *gradientColors;
@property CGPoint gradientStartPoint;
@property 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
@property (nonatomic, assign) THLabelFadeTruncatingMode fadeTruncatingMode;
@property THLabelFadeTruncatingMode fadeTruncatingMode;
```

You can fade in/out your label by setting the `fadeTruncatingMode` property. Default value is `THLabelFadeTruncatingModeNone`. The options are `THLabelFadeTruncatingModeTail`, `THLabelFadeTruncatingModeHead` and `THLabelFadeTruncatingModeHeadAndTail`.

``` objective-c
@property (nonatomic, assign) UIEdgeInsets textInsets;
@property (nonatomic, assign) IBInspectable BOOL automaticallyAdjustTextInsets;
@property UIEdgeInsets textInsets;
@property 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.
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.

## Notes

THLabel respects (unlike UILabel) the `contentMode` property, which is used for vertical alignment. The `textAlignment` still has the higher priority, when it comes to horizontal alignment.

However THLabel doesn't respect the `numberOfLines` property, because Core Text doesn't support it natively. If you would like to have multiple lines, set `lineBreakMode` to `NSLineBreakByWordWrapping`.

THLabels are slower to draw than UILabels, so be aware of that.

## Credits
Expand All @@ -107,6 +113,6 @@ Distributed under the permissive zlib license. See the LICENSE file for more inf

Tobias Hagemann

- http://www.tobiha.de/
- http://tobiha.de/
- [email protected]
- http://www.twitter.com/MuscleRumble
- https://twitter.com/MuscleRumble
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.7

- Set maximum width to preferredMaxLayoutWidth for intrinsicContentSize.
- Fixed warning.

Version 1.4.6

- Removed support for IB_DESIGNABLE and IBInspectable, until it doesn't cause problems with CocoaPods. Please us `ibdesignable` branch, if you're interested in this feature and not using CocoaPods.
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.6'
s.version = '1.4.7'
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
4 changes: 2 additions & 2 deletions THLabel/THLabel.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//
// THLabel.h
//
// Version 1.4.6
// Version 1.4.7
//
// Created by Tobias Hagemann on 11/25/12.
// Copyright (c) 2014 tobiha.de. All rights reserved.
// Copyright (c) 2015 tobiha.de. All rights reserved.
//
// Original source and inspiration from:
// FXLabel by Nick Lockwood,
Expand Down
8 changes: 6 additions & 2 deletions THLabel/THLabel.m
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//
// THLabel.m
//
// Version 1.4.6
// Version 1.4.7
//
// Created by Tobias Hagemann on 11/25/12.
// Copyright (c) 2014 tobiha.de. All rights reserved.
// Copyright (c) 2015 tobiha.de. All rights reserved.
//
// Original source and inspiration from:
// FXLabel by Nick Lockwood,
Expand Down Expand Up @@ -427,7 +427,11 @@ - (void)drawRect:(CGRect)rect {
- (CTFrameRef)frameRefFromSize:(CGSize)size textRectOutput:(CGRect *)textRectOutput CF_RETURNS_RETAINED {
// Set up font.
CTFontRef fontRef = CTFontCreateWithName((__bridge CFStringRef)self.font.fontName, self.font.pointSize, NULL);
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_6_0
CTTextAlignment alignment = NSTextAlignmentToCTTextAlignment(self.textAlignment);
#else
CTTextAlignment alignment = NSTextAlignmentToCTTextAlignment ? NSTextAlignmentToCTTextAlignment(self.textAlignment) : [self CTTextAlignmentFromNSTextAlignment:self.textAlignment];
#endif
CTLineBreakMode lineBreakMode = (CTLineBreakMode)self.lineBreakMode;
CGFloat lineSpacing = self.lineSpacing;
CTParagraphStyleSetting paragraphStyleSettings[] = {
Expand Down

0 comments on commit ba33b43

Please sign in to comment.