Skip to content

Commit

Permalink
Updated to version 1.4.6
Browse files Browse the repository at this point in the history
  • Loading branch information
tobihagemann committed Dec 14, 2014
1 parent 8403124 commit 6d39af2
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 67 deletions.
30 changes: 15 additions & 15 deletions Example/THLabelExample/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6254" systemVersion="14B25" 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"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
</dependencies>
<scenes>
<!--Basic-->
Expand All @@ -18,19 +18,19 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="RvV-Ry-Pmc">
<rect key="frame" x="300" y="20" width="1" height="32"/>
<rect key="frame" x="300" y="20" width="1" height="34"/>
<constraints>
<constraint firstAttribute="width" constant="1" id="Idk-oI-pQy"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="242-9J-wkw">
<rect key="frame" x="300" y="104" width="1" height="32"/>
<rect key="frame" x="300" y="104" width="1" height="34"/>
<constraints>
<constraint firstAttribute="width" constant="1" id="7H9-cU-Chf"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" text="Inner Shadow" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7Hs-P2-hla" customClass="THLabel">
<rect key="frame" x="173" y="136" width="255" height="48"/>
<rect key="frame" x="173" y="138" width="254" height="48"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="40"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
Expand All @@ -50,13 +50,13 @@
</variation>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="f7f-G5-eel">
<rect key="frame" x="300" y="184" width="1" height="32"/>
<rect key="frame" x="300" y="186" width="1" height="34"/>
<constraints>
<constraint firstAttribute="width" constant="1" id="mwt-jD-Kbj"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" text="Stroke" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5jH-TU-5Wy" customClass="THLabel">
<rect key="frame" x="237" y="216" width="127" height="54"/>
<rect key="frame" x="240" y="220" width="120" height="48"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="40"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
Expand All @@ -73,13 +73,13 @@
</variation>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="GY1-3x-3u4">
<rect key="frame" x="300" y="270" width="1" height="31"/>
<rect key="frame" x="300" y="268" width="1" height="35"/>
<constraints>
<constraint firstAttribute="width" constant="1" id="tGI-oT-twv"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" text="Fill Gradient" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Nq3-xL-Qnv" customClass="THLabel">
<rect key="frame" x="188" y="301" width="224" height="48"/>
<rect key="frame" x="189" y="303" width="222" height="48"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="40"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
Expand All @@ -96,13 +96,13 @@
</variation>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="zru-we-rnl">
<rect key="frame" x="300" y="349" width="1" height="32"/>
<rect key="frame" x="300" y="351" width="1" height="34"/>
<constraints>
<constraint firstAttribute="width" constant="1" id="6zq-Xu-jdY"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" text="Fade Truncating" lineBreakMode="clip" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="4hn-LK-JBo" customClass="THLabel">
<rect key="frame" x="160" y="381" width="280" height="48"/>
<rect key="frame" x="160" y="385" width="280" height="48"/>
<constraints>
<constraint firstAttribute="width" constant="280" id="i8g-AK-I01"/>
</constraints>
Expand All @@ -114,13 +114,13 @@
</variation>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Tll-cY-m2c">
<rect key="frame" x="300" y="429" width="1" height="32"/>
<rect key="frame" x="300" y="433" width="1" height="34"/>
<constraints>
<constraint firstAttribute="width" constant="1" id="nbB-o5-t9w"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" text="Everything" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Rm8-tw-CKi" customClass="THLabel">
<rect key="frame" x="197" y="461" width="206" height="58"/>
<rect key="frame" x="203" y="467" width="195" height="50"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="40"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
Expand Down Expand Up @@ -154,13 +154,13 @@
</variation>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="yMb-iY-HPI">
<rect key="frame" x="300" y="519" width="1" height="32"/>
<rect key="frame" x="300" y="517" width="1" height="34"/>
<constraints>
<constraint firstAttribute="width" constant="1" id="c0E-Sw-2rX"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" text="Shadow Blur" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bgk-sv-MPR" customClass="THLabel">
<rect key="frame" x="180" y="52" width="241" height="52"/>
<rect key="frame" x="182" y="54" width="236" height="50"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="40"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
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.5, November 12th, 2014
Version 1.4.6, December 14th, 2014

Copyright (c) 2014 Tobias Hagemann, tobiha.de

Expand Down
2 changes: 1 addition & 1 deletion 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.5'`
1. Add the following line in the project's Podfile file: `pod 'THLabel', '~> 1.4.6'`
2. Run the command `pod install` from the Podfile folder directory.

### Manual Installation
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.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.
- Fixed bug regarding gradients introduced in last version.

Version 1.4.5

- Added support for IB_DESIGNABLE and IBInspectable, only available with Xcode 6.
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.5'
s.version = '1.4.6'
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
34 changes: 12 additions & 22 deletions THLabel/THLabel.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// THLabel.h
//
// Version 1.4.5
// Version 1.4.6
//
// Created by Tobias Hagemann on 11/25/12.
// Copyright (c) 2014 tobiha.de. All rights reserved.
Expand Down Expand Up @@ -42,15 +42,6 @@
// 3. This notice may not be removed or altered from any source distribution.
//


#ifndef IB_DESIGNABLE
#define IB_DESIGNABLE
#endif
#ifndef IBInspectable
#define IBInspectable
#endif


#import <UIKit/UIKit.h>

typedef NS_ENUM(NSInteger, THLabelStrokePosition) {
Expand All @@ -66,31 +57,30 @@ typedef NS_OPTIONS(NSUInteger, THLabelFadeTruncatingMode) {
THLabelFadeTruncatingModeHeadAndTail = THLabelFadeTruncatingModeHead | THLabelFadeTruncatingModeTail
};

IB_DESIGNABLE
@interface THLabel : UILabel

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

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

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

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

@property (nonatomic, strong) IBInspectable UIColor *gradientStartColor;
@property (nonatomic, strong) IBInspectable UIColor *gradientEndColor;
@property (nonatomic, strong) UIColor *gradientStartColor;
@property (nonatomic, strong) UIColor *gradientEndColor;
@property (nonatomic, copy) NSArray *gradientColors;
@property (nonatomic, assign) CGPoint gradientStartPoint;
@property (nonatomic, assign) CGPoint gradientEndPoint;

@property (nonatomic, assign) THLabelFadeTruncatingMode fadeTruncatingMode;

@property (nonatomic, assign) UIEdgeInsets textInsets;
@property (nonatomic, assign) IBInspectable BOOL automaticallyAdjustTextInsets;
@property (nonatomic, assign) BOOL automaticallyAdjustTextInsets;

@end
30 changes: 3 additions & 27 deletions THLabel/THLabel.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// THLabel.m
//
// Version 1.4.5
// Version 1.4.6
//
// Created by Tobias Hagemann on 11/25/12.
// Copyright (c) 2014 tobiha.de. All rights reserved.
Expand Down Expand Up @@ -54,10 +54,6 @@
#import "THLabel.h"

@implementation THLabel
#ifdef TARGET_INTERFACE_BUILDER
@synthesize gradientStartColor = _gradientStartColor;
@synthesize gradientEndColor = _gradientEndColor;
#endif

- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
Expand Down Expand Up @@ -130,14 +126,11 @@ - (UIColor *)gradientStartColor {
}

- (void)setGradientStartColor:(UIColor *)gradientStartColor {
#ifdef TARGET_INTERFACE_BUILDER
_gradientStartColor = gradientStartColor;
#endif
if (gradientStartColor == nil) {
self.gradientColors = nil;
} else if (self.gradientColors.count < 2) {
self.gradientColors = @[gradientStartColor, gradientStartColor];
} else if ([self.gradientColors.firstObject isEqual:gradientStartColor]) {
} else if (![self.gradientColors.firstObject isEqual:gradientStartColor]) {
NSMutableArray *colors = [self.gradientColors mutableCopy];
colors[0] = gradientStartColor;
self.gradientColors = colors;
Expand All @@ -149,14 +142,11 @@ - (UIColor *)gradientEndColor {
}

- (void)setGradientEndColor:(UIColor *)gradientEndColor {
#ifdef TARGET_INTERFACE_BUILDER
_gradientEndColor = gradientEndColor;
#endif
if (gradientEndColor == nil) {
self.gradientColors = nil;
} else if (self.gradientColors.count < 2) {
self.gradientColors = @[gradientEndColor, gradientEndColor];
} else if ([self.gradientColors.lastObject isEqual:gradientEndColor]) {
} else if (![self.gradientColors.lastObject isEqual:gradientEndColor]) {
NSMutableArray *colors = [self.gradientColors mutableCopy];
colors[colors.count - 1] = gradientEndColor;
self.gradientColors = colors;
Expand Down Expand Up @@ -284,20 +274,6 @@ - (void)drawRect:(CGRect)rect {
[gradientColors addObject:(__bridge id)color.CGColor];
}

#ifdef TARGET_INTERFACE_BUILDER
[gradientColors removeAllObjects];
if (_gradientStartColor && _gradientEndColor) {
[gradientColors addObject:(__bridge id)_gradientStartColor.CGColor];
[gradientColors addObject:(__bridge id)_gradientEndColor.CGColor];
} else if (_gradientStartColor) {
[gradientColors addObject:(__bridge id)_gradientStartColor.CGColor];
[gradientColors addObject:(__bridge id)_gradientStartColor.CGColor];
} else if (_gradientEndColor) {
[gradientColors addObject:(__bridge id)_gradientEndColor.CGColor];
[gradientColors addObject:(__bridge id)_gradientEndColor.CGColor];
}
#endif

// Create gradient.
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGGradientRef gradient = CGGradientCreateWithColors(colorSpace, (__bridge CFArrayRef)gradientColors, NULL);
Expand Down

0 comments on commit 6d39af2

Please sign in to comment.