Skip to content

Commit

Permalink
Perform “manual” update in setFrame and setBounds ONLY on iOS 8.0.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
cbpowell committed Dec 14, 2014
1 parent 72f9a1f commit 0b1b10c
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions MarqueeLabel.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@
#import "MarqueeLabel.h"
#import <QuartzCore/QuartzCore.h>

// Notification strings
NSString *const kMarqueeLabelControllerRestartNotification = @"MarqueeLabelViewControllerRestart";
NSString *const kMarqueeLabelShouldLabelizeNotification = @"MarqueeLabelShouldLabelizeNotification";
NSString *const kMarqueeLabelShouldAnimateNotification = @"MarqueeLabelShouldAnimateNotification";
NSString *const kMarqueeLabelAnimationCompletionBlock = @"MarqueeLabelAnimationCompletionBlock";

// Animation completion block
typedef void(^MLAnimationCompletionBlock)(BOOL finished);

// iOS Version check for iOS 8.0.0
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)

// Helpers
@interface UIView (MarqueeLabelHelpers)
- (UIViewController *)firstAvailableViewController;
Expand Down Expand Up @@ -993,12 +998,23 @@ - (void)labelReturnedToHome:(BOOL)finished {

- (void)setFrame:(CGRect)frame {
[super setFrame:frame];
[self updateSublabelAndLocationsAndBeginScroll:!self.orientationWillChange];

// Check if device is running iOS 8.0.0
if(SYSTEM_VERSION_EQUAL_TO(@"8.0.0")) {
// If so, force update because layoutSubviews is not called
[self updateSublabelAndLocationsAndBeginScroll:!self.orientationWillChange];
}
}

- (void)setBounds:(CGRect)bounds {
[super setBounds:bounds];
[self updateSublabelAndLocationsAndBeginScroll:!self.orientationWillChange];

// Check if device is running iOS 8.0.0
if(SYSTEM_VERSION_EQUAL_TO(@"8.0.0")) {
// If so, force update because layoutSubviews is not called
[self updateSublabelAndLocationsAndBeginScroll:!self.orientationWillChange];
}

}

#pragma mark - Modified UILabel Methods/Getters/Setters
Expand Down Expand Up @@ -1420,7 +1436,7 @@ - (CGFloat)YforCurveAt:(CGFloat)t withControlPoints:(NSArray *)controlPoints
CGPoint P2 = [controlPoints[2] CGPointValue];
CGPoint P3 = [controlPoints[3] CGPointValue];

// Per http://en.wikipedia.org/wiki/Bézier_curve#Cubic_B.C3.A9zier_curves
// Per http://en.wikipedia.org/wiki/Bezier_curve#Cubic_B.C3.A9zier_curves
return powf((1 - t),3) * P0.y +
3.0f * powf(1 - t, 2) * t * P1.y +
3.0f * (1 - t) * powf(t, 2) * P2.y +
Expand All @@ -1435,7 +1451,7 @@ - (CGFloat)XforCurveAt:(CGFloat)t withControlPoints:(NSArray *)controlPoints
CGPoint P2 = [controlPoints[2] CGPointValue];
CGPoint P3 = [controlPoints[3] CGPointValue];

// Per http://en.wikipedia.org/wiki/Bézier_curve#Cubic_B.C3.A9zier_curves
// Per http://en.wikipedia.org/wiki/Bezier_curve#Cubic_B.C3.A9zier_curves
return powf((1 - t),3) * P0.x +
3.0f * powf(1 - t, 2) * t * P1.x +
3.0f * (1 - t) * powf(t, 2) * P2.x +
Expand Down

0 comments on commit 0b1b10c

Please sign in to comment.