Skip to content

Commit

Permalink
Merge branch 'fcanas-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
TomKnig committed Jan 5, 2015
2 parents 6ee9891 + 5660f44 commit 9930067
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 32 deletions.
6 changes: 3 additions & 3 deletions Classes/NSString+Morphing.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

#import <Foundation/Foundation.h>

#define kTOMSDictionaryKeyMergedString @"mergedString"
#define kTOMSDictionaryKeyAdditionRanges @"additionRanges"
#define kTOMSDictionaryKeyDeletionRanges @"deletionRanges"
extern NSString * const kTOMSDictionaryKeyMergedString;
extern NSString * const kTOMSDictionaryKeyAdditionRanges;
extern NSString * const kTOMSDictionaryKeyDeletionRanges;

@interface NSString (Morphing)

Expand Down
4 changes: 4 additions & 0 deletions Classes/NSString+Morphing.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

#import "NSString+Morphing.h"

NSString * const kTOMSDictionaryKeyMergedString = @"mergedString";
NSString * const kTOMSDictionaryKeyAdditionRanges = @"additionRanges";
NSString * const kTOMSDictionaryKeyDeletionRanges = @"deletionRanges";

@implementation NSString (Morphing)

- (NSUInteger)toms_unicodeLength
Expand Down
8 changes: 4 additions & 4 deletions Classes/TOMSMorphingLabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
@interface TOMSMorphingLabel : UILabel

@property (readonly, atomic, strong) NSString *targetText;
@property (nonatomic, assign) CGFloat animationDuration;
@property (nonatomic, assign) CGFloat characterAnimationOffset;
@property (nonatomic, assign) CGFloat characterShrinkFactor;
@property (nonatomic, assign, getter=isMorphingEnabled) BOOL morphingEnabled;
@property (nonatomic, assign) IBInspectable CGFloat animationDuration;
@property (nonatomic, assign) IBInspectable CGFloat characterAnimationOffset;
@property (nonatomic, assign) IBInspectable CGFloat characterShrinkFactor;
@property (nonatomic, assign, getter=isMorphingEnabled) IBInspectable BOOL morphingEnabled;

- (void)setTextWithoutMorphing:(NSString *)text;
- (void)setText:(NSString*)text withCompletionBlock:(void (^)(void))block;
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ The configureable properties are defined as follows:
## Changelog
#### 0.5.1
* made custom configureable properties accessible by Interface Builder
#### 0.5.0
* broke a strong reference cycle between `CADisplayLink` and `TOMSMorphingLabel`
* added invokation of the completion block when setting text without animations
Expand Down Expand Up @@ -107,6 +110,7 @@ The best way to contribute is by submitting a pull request or a [new Github issu
* @wanderwaltz broke a strong reference cycle between `CADisplayLink` and `TOMSMorphingLabel` in version 0.5.0
* @wanderwaltz added invokation of the completion block when setting text without animations in version 0.5.0
* @wanderwaltz made `TOMSMorphingLabel` respect the global `[UIView areAnimationsEnabled]` state in version 0.5.0
* @fcanas made custom configureable properties accessible by Interface Builder
## Author
Expand Down
2 changes: 1 addition & 1 deletion TOMSMorphingLabel.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "TOMSMorphingLabel"
s.version = "0.5.0"
s.version = "0.5.1"
s.summary = "Configurable morphing transitions between text values of a label."
s.homepage = "https://github.com/TomKnig/TOMSMorphingLabel"
s.license = 'MIT'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,43 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6162" systemVersion="14A238h" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="vXZ-lx-hvc">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6254" systemVersion="14C78c" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="vXZ-lx-hvc">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6160"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="ufC-wZ-h7g">
<objects>
<viewController id="vXZ-lx-hvc" customClass="ViewController" customModuleProvider="" sceneMemberID="viewController">
<viewController id="vXZ-lx-hvc" customClass="ViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="jyV-Pf-zRb"/>
<viewControllerLayoutGuide type="bottom" id="2fi-mo-0CV"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="kh9-bI-dsS">
<rect key="frame" x="0.0" y="0.0" width="480" height="480"/>
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bYm-vM-oxh" customClass="TOMSMorphingLabel">
<rect key="frame" x="16" y="20" width="568" height="42"/>
<constraints>
<constraint firstAttribute="height" constant="42" id="Dqz-SO-1Kc"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="32"/>
<color key="textColor" red="0.10196078431372549" green="0.83921568627450982" blue="0.99215686274509807" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="bYm-vM-oxh" firstAttribute="trailing" secondItem="kh9-bI-dsS" secondAttribute="trailingMargin" id="37n-xh-oUZ"/>
<constraint firstItem="bYm-vM-oxh" firstAttribute="top" secondItem="jyV-Pf-zRb" secondAttribute="bottom" id="LBI-uM-JkT"/>
<constraint firstItem="bYm-vM-oxh" firstAttribute="leading" secondItem="kh9-bI-dsS" secondAttribute="leadingMargin" id="ks5-Ow-fW8"/>
</constraints>
</view>
<connections>
<outlet property="morphingLabel" destination="bYm-vM-oxh" id="70H-Ob-Ufu"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
</objects>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
}
],
"info" : {
Expand Down
29 changes: 9 additions & 20 deletions TOMSMorphingLabelExample/TOMSMorphingLabelExample/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#import <TOMSMorphingLabel/TOMSMorphingLabel.h>

@interface ViewController ()
@property (weak, nonatomic) IBOutlet TOMSMorphingLabel *morphingLabel;
@property (nonatomic, assign) NSInteger idx;
@property (nonatomic, strong) NSArray *textValues;
@end
Expand All @@ -19,21 +20,8 @@ @implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];

self.idx = 0;

CGRect frame = CGRectMake(0, 42, self.view.frame.size.width, 42);
TOMSMorphingLabel *label = [[TOMSMorphingLabel alloc] initWithFrame:frame];

label.font = [UIFont systemFontOfSize:32];
label.textColor = [UIColor colorWithRed:0.102 green:0.839 blue:0.992 alpha: 1];
label.textAlignment = NSTextAlignmentCenter;

[self.view addSubview:label];
[label setText:@"Test" withCompletionBlock:^{
NSLog(@"First label animation completed");
}];

[self performSelector:@selector(toggleTextForLabel:) withObject:label afterDelay:2];
_idx = 0;
[self toggleText];
}

#pragma mark - toggling text
Expand All @@ -60,12 +48,13 @@ - (void)setIdx:(NSInteger)idx
_idx = MAX(0, MIN(idx, idx % [self.textValues count]));
}

- (void)toggleTextForLabel:(UILabel *)label
- (void)toggleText
{
label.text = self.textValues[self.idx++];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self toggleTextForLabel:label];
});
self.morphingLabel.text = self.textValues[self.idx++];

[self performSelector:@selector(toggleText)
withObject:nil
afterDelay:2];
}

@end

0 comments on commit 9930067

Please sign in to comment.