Skip to content

Commit

Permalink
Merge branch 'stepanhruda-no-morphing'
Browse files Browse the repository at this point in the history
  • Loading branch information
tomknig committed Jul 15, 2014
2 parents 46efdde + 9acb247 commit 8bbd386
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 7 deletions.
3 changes: 3 additions & 0 deletions Classes/TOMSMorphingLabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@
@property (nonatomic, assign) CGFloat animationDuration;
@property (nonatomic, assign) CGFloat characterAnimationOffset;
@property (nonatomic, assign) CGFloat characterShrinkFactor;
@property (nonatomic, assign, getter=isMorphingEnabled) BOOL morphingEnabled;

- (void)setTextWithoutMorphing:(NSString *)text;

@end
19 changes: 16 additions & 3 deletions Classes/TOMSMorphingLabel.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder
- (void)designatedInitialization
{
_displayLinkDuration = -1;
_morphingEnabled = YES;
self.animating = NO;

self.displayLink = [CADisplayLink displayLinkWithTarget:self
Expand All @@ -98,6 +99,14 @@ - (void)numberOfAttributionStagesShouldChange
}
}

- (void)setTextWithoutMorphing:(NSString *)text
{
BOOL wasMorphingEnabled = self.isMorphingEnabled;
self.morphingEnabled = NO;
self.text = text;
self.morphingEnabled = wasMorphingEnabled;
}

- (void)setDisplayLinkDuration:(CFTimeInterval)displayLinkDuration
{
_displayLinkDuration = displayLinkDuration;
Expand Down Expand Up @@ -227,9 +236,13 @@ - (NSArray *)deletionRanges

- (void)setText:(NSString *)text
{
self.nextText = text;
if (self.displayLinkDuration > 0) {
[self beginMorphing];
if (self.isMorphingEnabled) {
self.nextText = text;
if (self.displayLinkDuration > 0) {
[self beginMorphing];
}
} else {
[super setText:text];
}
}

Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ it, simply add the following line to your Podfile:

```ruby
platform :ios, '7.0'
pod "TOMSMorphingLabel", "~> 0.2.1"
pod "TOMSMorphingLabel", "~> 0.2.2"
```

## Usage
Expand Down Expand Up @@ -48,16 +48,23 @@ The configureable properties are defined as follows:
</tr>
<tr>
<td><tt>characterAnimationOffset: CGFloat</tt></td>
<td>Spatial propagation speed of the character shrink and alpha effect.. Default: 0.25</td>
<td>Spatial propagation speed of the character shrink and alpha effect. Default: 0.25</td>
</tr>
<tr>
<td><tt>characterShrinkFactor: CGFloat</tt></td>
<td>Factor that the scale of a completely disappeared character is divided by. Default: 4</td>
</tr>
<tr>
<td><tt>morphingEnabled: BOOL</tt></td>
<td>Defines whether the morphing transition between text values is enabled. Default: YES</td>
</tr>
</table>

## Changelog

#### 0.2.2
* added property to disable morphing

#### 0.2.1
* added support for iOS6

Expand All @@ -73,6 +80,7 @@ I'd love to see your ideas for improving this library!
The best way to contribute is by submitting a pull request or a [new Github issue](https://github.com/TomKnig/TOMSMorphingLabel/issues/new). :octocat:

* @andrebraga added support for iOS6 in version 0.2.1
* @stepanhruda added property to disable morphing in version 0.2.2

## 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.2.1"
s.version = "0.2.2"
s.summary = "Configurable morphing transitions between text values of a label."
s.homepage = "https://github.com/TomKnig/TOMSMorphingLabel"
s.license = 'MIT'
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8bbd386

Please sign in to comment.