From a4612b15d672f6f2f72eeb6678d14fc95a6d3ef7 Mon Sep 17 00:00:00 2001 From: Ricardo Pereira Date: Tue, 18 Feb 2014 16:31:44 +0000 Subject: [PATCH 01/12] Rebase --- TSMessages/Views/TSBlurView.h | 0 TSMessages/Views/TSBlurView.m | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 TSMessages/Views/TSBlurView.h mode change 100644 => 100755 TSMessages/Views/TSBlurView.m diff --git a/TSMessages/Views/TSBlurView.h b/TSMessages/Views/TSBlurView.h old mode 100644 new mode 100755 diff --git a/TSMessages/Views/TSBlurView.m b/TSMessages/Views/TSBlurView.m old mode 100644 new mode 100755 From bb95316cdcd2dbc8c6ff4f7047f75dc345f8f42d Mon Sep 17 00:00:00 2001 From: Ricardo Pereira Date: Tue, 18 Feb 2014 16:49:26 +0000 Subject: [PATCH 02/12] Rebase --- TSMessages/Classes/TSMessage.h | 6 +++- TSMessages/Classes/TSMessage.m | 31 +++++++++++--------- TSMessages/Views/TSBlurView.h | 0 TSMessages/Views/TSBlurView.m | 0 TSMessages/Views/TSMessageView.h | 10 +++++-- TSMessages/Views/TSMessageView.m | 50 +++++++++++++++++++++++--------- 6 files changed, 67 insertions(+), 30 deletions(-) mode change 100755 => 100644 TSMessages/Views/TSBlurView.h mode change 100755 => 100644 TSMessages/Views/TSBlurView.m diff --git a/TSMessages/Classes/TSMessage.h b/TSMessages/Classes/TSMessage.h index 4156f5d0..c5d74cd2 100755 --- a/TSMessages/Classes/TSMessage.h +++ b/TSMessages/Classes/TSMessage.h @@ -37,6 +37,7 @@ typedef NS_ENUM(NSInteger, TSMessageNotificationType) { TSMessageNotificationTypeError, TSMessageNotificationTypeSuccess }; + typedef NS_ENUM(NSInteger, TSMessageNotificationPosition) { TSMessageNotificationPositionTop = 0, TSMessageNotificationPositionBottom @@ -95,6 +96,7 @@ typedef NS_ENUM(NSInteger,TSMessageNotificationDuration) { @param buttonCallback The block that should be executed, when the user tapped on the button @param messagePosition The position of the message on the screen @param dismissingEnabled Should the message be dismissed when the user taps/swipes it + @param messageAlign The alignment of the message on the screen */ + (void)showNotificationInViewController:(UIViewController *)viewController title:(NSString *)title @@ -106,7 +108,9 @@ typedef NS_ENUM(NSInteger,TSMessageNotificationDuration) { buttonTitle:(NSString *)buttonTitle buttonCallback:(void (^)())buttonCallback atPosition:(TSMessageNotificationPosition)messagePosition - canBeDismissedByUser:(BOOL)dismissingEnabled; + canBeDismisedByUser:(BOOL)dismissingEnabled + textAlign:(NSTextAlignment)messageAlign; + /** Fades out the currently displayed notification. If another notification is in the queue, the next one will be displayed automatically diff --git a/TSMessages/Classes/TSMessage.m b/TSMessages/Classes/TSMessage.m index 5fbb149e..0c7de2a1 100755 --- a/TSMessages/Classes/TSMessage.m +++ b/TSMessages/Classes/TSMessage.m @@ -27,7 +27,7 @@ - (void)fadeOutNotification:(TSMessageView *)currentView; @implementation TSMessage -static TSMessage *sharedMessage; +static TSMessage *sharedMessages; static BOOL notificationActive; static BOOL _useiOS7Style; @@ -37,11 +37,11 @@ @implementation TSMessage + (TSMessage *)sharedMessage { - if (!sharedMessage) + if (!sharedMessages) { - sharedMessage = [[[self class] alloc] init]; + sharedMessages = [[[self class] alloc] init]; } - return sharedMessage; + return sharedMessages; } @@ -80,7 +80,8 @@ + (void)showNotificationInViewController:(UIViewController *)viewController buttonTitle:nil buttonCallback:nil atPosition:TSMessageNotificationPositionTop - canBeDismissedByUser:YES]; + canBeDismisedByUser:YES + textAlign:NSTextAlignmentLeft]; } @@ -94,7 +95,8 @@ + (void)showNotificationInViewController:(UIViewController *)viewController buttonTitle:(NSString *)buttonTitle buttonCallback:(void (^)())buttonCallback atPosition:(TSMessageNotificationPosition)messagePosition - canBeDismissedByUser:(BOOL)dismissingEnabled + canBeDismisedByUser:(BOOL)dismissingEnabled + textAlign:(NSTextAlignment)messageAlign { // Create the TSMessageView TSMessageView *v = [[TSMessageView alloc] initWithTitle:title @@ -107,7 +109,8 @@ + (void)showNotificationInViewController:(UIViewController *)viewController buttonTitle:buttonTitle buttonCallback:buttonCallback atPosition:messagePosition - canBeDismissedByUser:dismissingEnabled]; + shouldBeDismissed:dismissingEnabled + textAlign:messageAlign]; [self prepareNotificationToBeShown:v]; } @@ -170,7 +173,7 @@ - (void)fadeInCurrentNotification currentNavigationController = (UINavigationController *)currentView.viewController; else currentNavigationController = (UINavigationController *)currentView.viewController.parentViewController; - + BOOL isViewIsUnderStatusBar = [[[currentNavigationController childViewControllers] firstObject] wantsFullScreenLayout]; if (!isViewIsUnderStatusBar && currentNavigationController.parentViewController == nil) { isViewIsUnderStatusBar = ![currentNavigationController isNavigationBarHidden]; // strange but true @@ -219,7 +222,7 @@ - (void)fadeInCurrentNotification } toPoint = CGPointMake(currentView.center.x, y); } - + dispatch_block_t animationBlock = ^{ currentView.center = toPoint; if (![TSMessage iOS7StyleEnabled]) { @@ -237,7 +240,7 @@ - (void)fadeInCurrentNotification animations:animationBlock completion:completionBlock]; } else { -#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 + #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 [UIView animateWithDuration:kTSMessageAnimationDuration + 0.1 delay:0 usingSpringWithDamping:0.8 @@ -245,7 +248,7 @@ - (void)fadeInCurrentNotification options:UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionAllowUserInteraction animations:animationBlock completion:completionBlock]; -#endif + #endif } if (currentView.duration == TSMessageNotificationDurationAutomatic) @@ -360,9 +363,9 @@ + (BOOL)iOS7StyleEnabled dispatch_once(&onceToken, ^{ // Decide wheter to use iOS 7 style or not based on the running device and the base sdk BOOL iOS7SDK = NO; -#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 - iOS7SDK = YES; -#endif + #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 + iOS7SDK = YES; + #endif _useiOS7Style = ! (TS_SYSTEM_VERSION_LESS_THAN(@"7.0") || !iOS7SDK); }); diff --git a/TSMessages/Views/TSBlurView.h b/TSMessages/Views/TSBlurView.h old mode 100755 new mode 100644 diff --git a/TSMessages/Views/TSBlurView.m b/TSMessages/Views/TSBlurView.m old mode 100755 new mode 100644 diff --git a/TSMessages/Views/TSMessageView.h b/TSMessages/Views/TSMessageView.h index b52cf221..afe54eae 100755 --- a/TSMessages/Views/TSMessageView.h +++ b/TSMessages/Views/TSMessageView.h @@ -39,6 +39,9 @@ /** The position of the message (top or bottom) */ @property (nonatomic, assign) TSMessageNotificationPosition messagePosition; +/** The alignment of the message (left, center, right, justified, natural) */ +@property (nonatomic, assign) NSTextAlignment messageAlignment; + /** Is the message currenlty fully displayed? Is set as soon as the message is really fully visible */ @property (nonatomic, assign) BOOL messageIsFullyDisplayed; @@ -56,7 +59,8 @@ @param buttonTitle The title for button (optional) @param buttonCallback The block that should be executed, when the user tapped on the button @param position The position of the message on the screen - @param dismissingEnabled Should this message be dismissed when the user taps/swipes it? + @param dismissAble Should this message be dismissed when the user taps/swipes it? + @param textAlign The align of the message on the screen */ - (id)initWithTitle:(NSString *)title subtitle:(NSString *)subtitle @@ -68,7 +72,9 @@ buttonTitle:(NSString *)buttonTitle buttonCallback:(void (^)())buttonCallback atPosition:(TSMessageNotificationPosition)position -canBeDismissedByUser:(BOOL)dismissingEnabled; + shouldBeDismissed:(BOOL)dismissAble + textAlign:(NSTextAlignment)alignment; + /** Fades out this notification view */ - (void)fadeMeOut; diff --git a/TSMessages/Views/TSMessageView.m b/TSMessages/Views/TSMessageView.m index 00177ed0..de7183e9 100755 --- a/TSMessages/Views/TSMessageView.m +++ b/TSMessages/Views/TSMessageView.m @@ -67,8 +67,8 @@ + (NSMutableDictionary *)notificationDesign { NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:TSDesignFileName]; _notificationDesign = [NSMutableDictionary dictionaryWithDictionary:[NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfFile:path] - options:kNilOptions - error:nil]]; + options:kNilOptions + error:nil]]; } return _notificationDesign; @@ -79,8 +79,8 @@ + (void)addNotificationDesignFromFile:(NSString *)filename { NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:filename]; NSDictionary *design = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfFile:path] - options:kNilOptions - error:nil]; + options:kNilOptions + error:nil]; [[TSMessageView notificationDesign] addEntriesFromDictionary:design]; } @@ -95,7 +95,8 @@ - (id)initWithTitle:(NSString *)title buttonTitle:(NSString *)buttonTitle buttonCallback:(void (^)())buttonCallback atPosition:(TSMessageNotificationPosition)position -canBeDismissedByUser:(BOOL)dismissingEnabled + shouldBeDismissed:(BOOL)dismissAble + textAlign:(NSTextAlignment)alignment { NSDictionary *notificationDesign = [TSMessageView notificationDesign]; @@ -107,6 +108,7 @@ - (id)initWithTitle:(NSString *)title _duration = duration; _viewController = viewController; _messagePosition = position; + _messageAlignment = alignment; self.callback = callback; self.buttonCallback = buttonCallback; @@ -141,7 +143,7 @@ - (id)initWithTitle:(NSString *)title } current = [notificationDesign valueForKey:currentString]; - + if (!image && [current valueForKey:@"imageName"]) { @@ -191,6 +193,13 @@ - (id)initWithTitle:(NSString *)title [[current valueForKey:@"shadowOffsetY"] floatValue])]; self.titleLabel.numberOfLines = 0; self.titleLabel.lineBreakMode = NSLineBreakByWordWrapping; + // Check alignment: layout has priority! + int align = [[current valueForKey:@"textAlignment"] intValue]; + if (align > 0) + self.titleLabel.textAlignment = align; + else + self.titleLabel.textAlignment = self.messageAlignment; + [self addSubview:self.titleLabel]; // Set up content label (if set) @@ -217,7 +226,12 @@ - (id)initWithTitle:(NSString *)title [self.contentLabel setShadowOffset:self.titleLabel.shadowOffset]; self.contentLabel.lineBreakMode = self.titleLabel.lineBreakMode; self.contentLabel.numberOfLines = 0; - + // Check alignment: layout has priority! + if (align > 0) + self.contentLabel.textAlignment = align; + else + self.contentLabel.textAlignment = self.messageAlignment; + [self addSubview:self.contentLabel]; } @@ -313,7 +327,7 @@ - (id)initWithTitle:(NSString *)title self.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin); } - if (dismissingEnabled) + if (dismissAble) { UISwipeGestureRecognizer *gestureRec = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(fadeMeOut)]; @@ -347,6 +361,11 @@ - (CGFloat)updateHeightOfMessageView 0.0); [self.titleLabel sizeToFit]; + // for title text alignment + CGRect currFrame = self.titleLabel.frame; + + self.titleLabel.frame = CGRectMake(currFrame.origin.x, currFrame.origin.y, screenWidth - TSMessageViewPadding - self.iconImageView.frame.origin.x - self.iconImageView.frame.size.width - TSMessageViewPadding - self.textSpaceLeft - self.textSpaceRight, currFrame.size.height); + if ([self.subtitle length]) { self.contentLabel.frame = CGRectMake(self.textSpaceLeft, @@ -355,6 +374,11 @@ - (CGFloat)updateHeightOfMessageView 0.0); [self.contentLabel sizeToFit]; + // for content text alignment + currFrame = self.contentLabel.frame; + + self.contentLabel.frame = CGRectMake(currFrame.origin.x, currFrame.origin.y, screenWidth - TSMessageViewPadding - self.iconImageView.frame.origin.x - self.iconImageView.frame.size.width - TSMessageViewPadding - self.textSpaceLeft - self.textSpaceRight, currFrame.size.height); + currentHeight = self.contentLabel.frame.origin.y + self.contentLabel.frame.size.height; } else @@ -404,20 +428,20 @@ - (CGFloat)updateHeightOfMessageView self.button.frame.size.width, self.button.frame.size.height); } - - + + CGRect backgroundFrame = CGRectMake(self.backgroundImageView.frame.origin.x, self.backgroundImageView.frame.origin.y, screenWidth, currentHeight); - + // increase frame of background view because of the spring animation if ([TSMessage iOS7StyleEnabled]) { if (self.messagePosition == TSMessageNotificationPositionTop) { float topOffset = 0.f; - + UINavigationController *navigationController = self.viewController.navigationController; if (!navigationController && [self.viewController isKindOfClass:[UINavigationController class]]) { navigationController = (UINavigationController *)self.viewController; @@ -435,7 +459,7 @@ - (CGFloat)updateHeightOfMessageView backgroundFrame = UIEdgeInsetsInsetRect(backgroundFrame, UIEdgeInsetsMake(0.f, 0.f, -30.f, 0.f)); } } - + self.backgroundImageView.frame = backgroundFrame; self.backgroundBlurView.frame = backgroundFrame; From 3b0dc87feef69205d5763d527a7f1d03bc35fe99 Mon Sep 17 00:00:00 2001 From: Ricardo Pereira Date: Tue, 18 Feb 2014 16:55:38 +0000 Subject: [PATCH 03/12] Update README.md --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index befd2dd7..a09c58b0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,13 @@ TSMessages ========== +**Edit** by [Ricardo Pereira](http://twitter.com/ricardopereiraw) +* Add text align support + +-------- + +** Original ** + This framework provides an easy to use class to show little notification views on the top of the screen. (à la Tweetbot). The notification moves from the top of the screen underneath the navigation bar and stays there for a few seconds, depending on the length of the displayed text. To dismiss a notification before the time runs out, the user can swipe it to the top or just tap it. @@ -110,4 +117,4 @@ Changes TODOs ----- -Currently empty \ No newline at end of file +Currently empty From bfd77361f143e2ae70c5a6717b0ccb2c2626b2f2 Mon Sep 17 00:00:00 2001 From: Ricardo Pereira Date: Tue, 18 Feb 2014 16:58:14 +0000 Subject: [PATCH 04/12] Update README.md TODOs --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a09c58b0..4b90593b 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ TSMessages ========== -**Edit** by [Ricardo Pereira](http://twitter.com/ricardopereiraw) +**Edited** by [Ricardo Pereira](http://twitter.com/ricardopereiraw) * Add text align support -------- -** Original ** +**Original** This framework provides an easy to use class to show little notification views on the top of the screen. (à la Tweetbot). @@ -117,4 +117,4 @@ Changes TODOs ----- -Currently empty +* iOS 7: Blur effect From b28373d6dbd7e3de16a6369980843c87f039c66d Mon Sep 17 00:00:00 2001 From: Ricardo Pereira Date: Tue, 18 Feb 2014 17:22:09 +0000 Subject: [PATCH 05/12] Rebase --- TSMessages/Classes/TSMessage.h | 2 +- TSMessages/Classes/TSMessage.m | 24 ++++++++++++------------ TSMessages/Views/TSMessageView.h | 4 ++-- TSMessages/Views/TSMessageView.m | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/TSMessages/Classes/TSMessage.h b/TSMessages/Classes/TSMessage.h index c5d74cd2..e1d28135 100755 --- a/TSMessages/Classes/TSMessage.h +++ b/TSMessages/Classes/TSMessage.h @@ -108,7 +108,7 @@ typedef NS_ENUM(NSInteger,TSMessageNotificationDuration) { buttonTitle:(NSString *)buttonTitle buttonCallback:(void (^)())buttonCallback atPosition:(TSMessageNotificationPosition)messagePosition - canBeDismisedByUser:(BOOL)dismissingEnabled + canBeDismissedByUser:(BOOL)dismissingEnabled textAlign:(NSTextAlignment)messageAlign; diff --git a/TSMessages/Classes/TSMessage.m b/TSMessages/Classes/TSMessage.m index 0c7de2a1..0903ade7 100755 --- a/TSMessages/Classes/TSMessage.m +++ b/TSMessages/Classes/TSMessage.m @@ -27,7 +27,7 @@ - (void)fadeOutNotification:(TSMessageView *)currentView; @implementation TSMessage -static TSMessage *sharedMessages; +static TSMessage *sharedMessage; static BOOL notificationActive; static BOOL _useiOS7Style; @@ -37,11 +37,11 @@ @implementation TSMessage + (TSMessage *)sharedMessage { - if (!sharedMessages) + if (!sharedMessage) { - sharedMessages = [[[self class] alloc] init]; + sharedMessage = [[[self class] alloc] init]; } - return sharedMessages; + return sharedMessage; } @@ -80,7 +80,7 @@ + (void)showNotificationInViewController:(UIViewController *)viewController buttonTitle:nil buttonCallback:nil atPosition:TSMessageNotificationPositionTop - canBeDismisedByUser:YES + canBeDismissedByUser:YES textAlign:NSTextAlignmentLeft]; } @@ -95,7 +95,7 @@ + (void)showNotificationInViewController:(UIViewController *)viewController buttonTitle:(NSString *)buttonTitle buttonCallback:(void (^)())buttonCallback atPosition:(TSMessageNotificationPosition)messagePosition - canBeDismisedByUser:(BOOL)dismissingEnabled + canBeDismissedByUser:(BOOL)dismissingEnabled textAlign:(NSTextAlignment)messageAlign { // Create the TSMessageView @@ -109,7 +109,7 @@ + (void)showNotificationInViewController:(UIViewController *)viewController buttonTitle:buttonTitle buttonCallback:buttonCallback atPosition:messagePosition - shouldBeDismissed:dismissingEnabled + canBeDismissedByUser:dismissingEnabled textAlign:messageAlign]; [self prepareNotificationToBeShown:v]; } @@ -173,7 +173,7 @@ - (void)fadeInCurrentNotification currentNavigationController = (UINavigationController *)currentView.viewController; else currentNavigationController = (UINavigationController *)currentView.viewController.parentViewController; - + BOOL isViewIsUnderStatusBar = [[[currentNavigationController childViewControllers] firstObject] wantsFullScreenLayout]; if (!isViewIsUnderStatusBar && currentNavigationController.parentViewController == nil) { isViewIsUnderStatusBar = ![currentNavigationController isNavigationBarHidden]; // strange but true @@ -240,7 +240,7 @@ - (void)fadeInCurrentNotification animations:animationBlock completion:completionBlock]; } else { - #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 [UIView animateWithDuration:kTSMessageAnimationDuration + 0.1 delay:0 usingSpringWithDamping:0.8 @@ -248,7 +248,7 @@ - (void)fadeInCurrentNotification options:UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionAllowUserInteraction animations:animationBlock completion:completionBlock]; - #endif +#endif } if (currentView.duration == TSMessageNotificationDurationAutomatic) @@ -363,9 +363,9 @@ + (BOOL)iOS7StyleEnabled dispatch_once(&onceToken, ^{ // Decide wheter to use iOS 7 style or not based on the running device and the base sdk BOOL iOS7SDK = NO; - #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 iOS7SDK = YES; - #endif +#endif _useiOS7Style = ! (TS_SYSTEM_VERSION_LESS_THAN(@"7.0") || !iOS7SDK); }); diff --git a/TSMessages/Views/TSMessageView.h b/TSMessages/Views/TSMessageView.h index afe54eae..a40b52bc 100755 --- a/TSMessages/Views/TSMessageView.h +++ b/TSMessages/Views/TSMessageView.h @@ -59,7 +59,7 @@ @param buttonTitle The title for button (optional) @param buttonCallback The block that should be executed, when the user tapped on the button @param position The position of the message on the screen - @param dismissAble Should this message be dismissed when the user taps/swipes it? + @param dismissingEnabled Should this message be dismissed when the user taps/swipes it? @param textAlign The align of the message on the screen */ - (id)initWithTitle:(NSString *)title @@ -72,7 +72,7 @@ buttonTitle:(NSString *)buttonTitle buttonCallback:(void (^)())buttonCallback atPosition:(TSMessageNotificationPosition)position - shouldBeDismissed:(BOOL)dismissAble +canBeDismissedByUser:(BOOL)dismissingEnabled textAlign:(NSTextAlignment)alignment; diff --git a/TSMessages/Views/TSMessageView.m b/TSMessages/Views/TSMessageView.m index de7183e9..33439a7f 100755 --- a/TSMessages/Views/TSMessageView.m +++ b/TSMessages/Views/TSMessageView.m @@ -95,7 +95,7 @@ - (id)initWithTitle:(NSString *)title buttonTitle:(NSString *)buttonTitle buttonCallback:(void (^)())buttonCallback atPosition:(TSMessageNotificationPosition)position - shouldBeDismissed:(BOOL)dismissAble +canBeDismissedByUser:(BOOL)dismissingEnabled textAlign:(NSTextAlignment)alignment { NSDictionary *notificationDesign = [TSMessageView notificationDesign]; @@ -327,7 +327,7 @@ - (id)initWithTitle:(NSString *)title self.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin); } - if (dismissAble) + if (dismissingEnabled) { UISwipeGestureRecognizer *gestureRec = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(fadeMeOut)]; From ade414b670e70ab5e2dac695b5e87bdecc538f2b Mon Sep 17 00:00:00 2001 From: Joan Romano Date: Fri, 7 Nov 2014 12:13:17 +0100 Subject: [PATCH 06/12] Add title view height to curtain vertical offset --- TSMessages/Classes/TSMessage.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TSMessages/Classes/TSMessage.m b/TSMessages/Classes/TSMessage.m index 0903ade7..0867cf9d 100755 --- a/TSMessages/Classes/TSMessage.m +++ b/TSMessages/Classes/TSMessage.m @@ -182,7 +182,7 @@ - (void)fadeInCurrentNotification { [currentNavigationController.view insertSubview:currentView belowSubview:[currentNavigationController navigationBar]]; - verticalOffset = [currentNavigationController navigationBar].bounds.size.height; + verticalOffset = MAX([currentNavigationController navigationBar].bounds.size.height, CGRectGetHeight(currentView.viewController.navigationItem.titleView.bounds)); if ([TSMessage iOS7StyleEnabled] || isViewIsUnderStatusBar) { addStatusBarHeightToVerticalOffset(); } From f397be96ae9d1958164ab66f4e52c44133c9d042 Mon Sep 17 00:00:00 2001 From: Joan Romano Date: Fri, 7 Nov 2014 12:17:20 +0100 Subject: [PATCH 07/12] Add background alpha to curtain design json --- TSMessages/Views/TSMessageView.m | 1 + 1 file changed, 1 insertion(+) diff --git a/TSMessages/Views/TSMessageView.m b/TSMessages/Views/TSMessageView.m index 33439a7f..2c2ca30c 100755 --- a/TSMessages/Views/TSMessageView.m +++ b/TSMessages/Views/TSMessageView.m @@ -166,6 +166,7 @@ - (id)initWithTitle:(NSString *)title _backgroundBlurView = [[TSBlurView alloc] init]; self.backgroundBlurView.autoresizingMask = (UIViewAutoresizingFlexibleWidth); self.backgroundBlurView.blurTintColor = [UIColor colorWithHexString:current[@"backgroundColor"]]; + self.backgroundBlurView.alpha = current[@"backgroundAlpha"] ? [current[@"backgroundAlpha"] floatValue] : 1.0; [self addSubview:self.backgroundBlurView]; } From 9ef6ba0649c4d6c16de933a699b9488cc31f7c49 Mon Sep 17 00:00:00 2001 From: Joan Romano Date: Sat, 8 Nov 2014 18:23:24 +0100 Subject: [PATCH 08/12] Iterate all title views to get vertical offset --- TSMessages/Classes/TSMessage.m | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/TSMessages/Classes/TSMessage.m b/TSMessages/Classes/TSMessage.m index 0867cf9d..f4e85533 100755 --- a/TSMessages/Classes/TSMessage.m +++ b/TSMessages/Classes/TSMessage.m @@ -182,7 +182,14 @@ - (void)fadeInCurrentNotification { [currentNavigationController.view insertSubview:currentView belowSubview:[currentNavigationController navigationBar]]; - verticalOffset = MAX([currentNavigationController navigationBar].bounds.size.height, CGRectGetHeight(currentView.viewController.navigationItem.titleView.bounds)); + + NSArray *titleViewsBounds = [currentView.viewController.navigationController.viewControllers valueForKeyPath:@"navigationItem.titleView.bounds"]; + __block CGFloat maxTitleViewHeight = 0.0; + [titleViewsBounds enumerateObjectsUsingBlock:^(NSValue *boundsValue, NSUInteger idx, BOOL *stop) { + CGRect rect = boundsValue.CGRectValue; + maxTitleViewHeight = CGRectGetHeight(rect) > maxTitleViewHeight ? CGRectGetHeight(rect) : maxTitleViewHeight; + }]; + verticalOffset = MAX([currentNavigationController navigationBar].bounds.size.height, maxTitleViewHeight); if ([TSMessage iOS7StyleEnabled] || isViewIsUnderStatusBar) { addStatusBarHeightToVerticalOffset(); } From d1633cacc76486eeec3e2a76761dcb92978c1a93 Mon Sep 17 00:00:00 2001 From: Joan Romano Date: Wed, 26 Nov 2014 18:29:05 +0100 Subject: [PATCH 09/12] Use normal UIView instead of TSBlurView --- TSMessages/Views/TSMessageView.m | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/TSMessages/Views/TSMessageView.m b/TSMessages/Views/TSMessageView.m index 2c2ca30c..b8de0e4b 100755 --- a/TSMessages/Views/TSMessageView.m +++ b/TSMessages/Views/TSMessageView.m @@ -8,7 +8,6 @@ #import "TSMessageView.h" #import "HexColor.h" -#import "TSBlurView.h" #import "TSMessage.h" @@ -45,7 +44,7 @@ @interface TSMessageView () @property (nonatomic, strong) UIButton *button; @property (nonatomic, strong) UIView *borderView; @property (nonatomic, strong) UIImageView *backgroundImageView; -@property (nonatomic, strong) TSBlurView *backgroundBlurView; // Only used in iOS 7 +@property (nonatomic, strong) UIView *backgroundView; // Only used in iOS 7 @property (nonatomic, assign) CGFloat textSpaceLeft; @property (nonatomic, assign) CGFloat textSpaceRight; @@ -162,12 +161,10 @@ - (id)initWithTitle:(NSString *)title } else { - // On iOS 7 and above use a blur layer instead (not yet finished) - _backgroundBlurView = [[TSBlurView alloc] init]; - self.backgroundBlurView.autoresizingMask = (UIViewAutoresizingFlexibleWidth); - self.backgroundBlurView.blurTintColor = [UIColor colorWithHexString:current[@"backgroundColor"]]; - self.backgroundBlurView.alpha = current[@"backgroundAlpha"] ? [current[@"backgroundAlpha"] floatValue] : 1.0; - [self addSubview:self.backgroundBlurView]; + _backgroundView = [[UIView alloc] init]; + self.backgroundView.autoresizingMask = (UIViewAutoresizingFlexibleWidth); + self.backgroundView.backgroundColor = [UIColor colorWithHexString:current[@"backgroundColor"] alpha:current[@"backgroundAlpha"] ? [current[@"backgroundAlpha"] floatValue] : 1.0]; + [self addSubview:self.backgroundView]; } UIColor *fontColor = [UIColor colorWithHexString:[current valueForKey:@"textColor"] @@ -462,7 +459,7 @@ - (CGFloat)updateHeightOfMessageView } self.backgroundImageView.frame = backgroundFrame; - self.backgroundBlurView.frame = backgroundFrame; + self.backgroundView.frame = backgroundFrame; return currentHeight; } From 120da44b51c7e73090dc05dcc9c2850f92a9d53c Mon Sep 17 00:00:00 2001 From: Joan Romano Date: Tue, 31 Mar 2015 13:41:39 +0200 Subject: [PATCH 10/12] Update TSMessage.m --- TSMessages/Classes/TSMessage.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TSMessages/Classes/TSMessage.m b/TSMessages/Classes/TSMessage.m index f4e85533..7f4d5a38 100755 --- a/TSMessages/Classes/TSMessage.m +++ b/TSMessages/Classes/TSMessage.m @@ -186,7 +186,7 @@ - (void)fadeInCurrentNotification NSArray *titleViewsBounds = [currentView.viewController.navigationController.viewControllers valueForKeyPath:@"navigationItem.titleView.bounds"]; __block CGFloat maxTitleViewHeight = 0.0; [titleViewsBounds enumerateObjectsUsingBlock:^(NSValue *boundsValue, NSUInteger idx, BOOL *stop) { - CGRect rect = boundsValue.CGRectValue; + CGRect rect = [boundsValue isEqual:NSNull.null] ? CGRectZero : boundsValue.CGRectValue; maxTitleViewHeight = CGRectGetHeight(rect) > maxTitleViewHeight ? CGRectGetHeight(rect) : maxTitleViewHeight; }]; verticalOffset = MAX([currentNavigationController navigationBar].bounds.size.height, maxTitleViewHeight); From 83b254a6aecf2e5d1d4a47b388b567773401a378 Mon Sep 17 00:00:00 2001 From: Joan Romano Date: Fri, 8 May 2015 09:23:16 +0200 Subject: [PATCH 11/12] Update TSMessageView.m --- TSMessages/Views/TSMessageView.m | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/TSMessages/Views/TSMessageView.m b/TSMessages/Views/TSMessageView.m index b8de0e4b..e9677796 100755 --- a/TSMessages/Views/TSMessageView.m +++ b/TSMessages/Views/TSMessageView.m @@ -428,8 +428,22 @@ - (CGFloat)updateHeightOfMessageView } + NSArray *titleViewsBounds = [self.viewController.navigationController.viewControllers valueForKeyPath:@"navigationItem.titleView.bounds"]; + __block CGFloat maxTitleViewHeight = 0.0; + CGFloat differenceHeight = 0.0; + [titleViewsBounds enumerateObjectsUsingBlock:^(NSValue *boundsValue, NSUInteger idx, BOOL *stop) { + CGRect rect = [boundsValue isEqual:NSNull.null] ? CGRectZero : boundsValue.CGRectValue; + maxTitleViewHeight = CGRectGetHeight(rect) > maxTitleViewHeight ? CGRectGetHeight(rect) : maxTitleViewHeight; + }]; + + if (maxTitleViewHeight > currentHeight) + { + differenceHeight = maxTitleViewHeight - currentHeight; + currentHeight += differenceHeight; + } + CGRect backgroundFrame = CGRectMake(self.backgroundImageView.frame.origin.x, - self.backgroundImageView.frame.origin.y, + MIN(self.backgroundImageView.frame.origin.y, -differenceHeight), screenWidth, currentHeight); From 2fc6c767a753f144b862635a8885d95c5da1ffeb Mon Sep 17 00:00:00 2001 From: Kirian Date: Tue, 7 Jul 2015 11:27:21 +0200 Subject: [PATCH 12/12] TSMessage has a dependency with 'HexColors'. HexColors in 2.3 version has renamed his file hexColor.h to hexColors.h Also, now we can align the text in the TSMessage - Rename import hexColors.h in TSMessageView - Update in methods with textAlign property in the TSDemoViewController --- ExampleProject/Example/TSDemoViewController.m | 15 ++++++++++----- TSMessages/Views/TSMessageView.m | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/ExampleProject/Example/TSDemoViewController.m b/ExampleProject/Example/TSDemoViewController.m index 3f30ef05..f11a058d 100644 --- a/ExampleProject/Example/TSDemoViewController.m +++ b/ExampleProject/Example/TSDemoViewController.m @@ -65,7 +65,8 @@ - (IBAction)didTapButton:(id)sender type:TSMessageNotificationTypeSuccess]; } atPosition:TSMessageNotificationPositionTop - canBeDismissedByUser:YES]; + canBeDismissedByUser:YES + textAlign:NSTextAlignmentCenter]; } - (IBAction)didTapToggleNavigationBar:(id)sender { @@ -92,7 +93,8 @@ - (IBAction)didTapCustomImage:(id)sender buttonTitle:nil buttonCallback:nil atPosition:TSMessageNotificationPositionTop - canBeDismissedByUser:YES]; + canBeDismissedByUser:YES + textAlign:NSTextAlignmentCenter]; } - (IBAction)didTapDismissCurrentMessage:(id)sender @@ -112,7 +114,8 @@ - (IBAction)didTapEndless:(id)sender buttonTitle:nil buttonCallback:nil atPosition:TSMessageNotificationPositionTop - canBeDismissedByUser:NO]; + canBeDismissedByUser:NO + textAlign:NSTextAlignmentCenter]; } - (IBAction)didTapLong:(id)sender @@ -127,7 +130,8 @@ - (IBAction)didTapLong:(id)sender buttonTitle:nil buttonCallback:nil atPosition:TSMessageNotificationPositionTop - canBeDismissedByUser:YES]; + canBeDismissedByUser:YES + textAlign:NSTextAlignmentCenter]; } - (IBAction)didTapBottom:(id)sender @@ -142,7 +146,8 @@ - (IBAction)didTapBottom:(id)sender buttonTitle:nil buttonCallback:nil atPosition:TSMessageNotificationPositionBottom - canBeDismissedByUser:YES]; + canBeDismissedByUser:YES + textAlign:NSTextAlignmentCenter]; } - (IBAction)didTapText:(id)sender diff --git a/TSMessages/Views/TSMessageView.m b/TSMessages/Views/TSMessageView.m index e9677796..90c68347 100755 --- a/TSMessages/Views/TSMessageView.m +++ b/TSMessages/Views/TSMessageView.m @@ -7,7 +7,7 @@ // #import "TSMessageView.h" -#import "HexColor.h" +#import "HexColors.h" #import "TSMessage.h"