From b647f381050e909a531eae857602c561c14eb2f0 Mon Sep 17 00:00:00 2001 From: Lucas Vidal Date: Wed, 11 Feb 2015 12:44:33 -0300 Subject: [PATCH 01/22] Add animated parameter to allow pop animation to be disabled --- Classes/ios/MMPopLabel.h | 7 +++++++ Classes/ios/MMPopLabel.m | 41 ++++++++++++++++++++++++---------------- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/Classes/ios/MMPopLabel.h b/Classes/ios/MMPopLabel.h index 9626160..f3bdcb2 100644 --- a/Classes/ios/MMPopLabel.h +++ b/Classes/ios/MMPopLabel.h @@ -27,7 +27,14 @@ + (MMPopLabel *)popLabelWithText:(NSString *)text; - (void)addButton:(UIButton *)button; + +- (void)popAtView:(UIView *)view animated: (BOOL) animated; + +//Keeping this method without animated boolean for retrocompatibility +//will use animations by default - (void)popAtView:(UIView *)view; + + - (void)dismiss; diff --git a/Classes/ios/MMPopLabel.m b/Classes/ios/MMPopLabel.m index 5aa5769..df8199d 100644 --- a/Classes/ios/MMPopLabel.m +++ b/Classes/ios/MMPopLabel.m @@ -177,8 +177,11 @@ - (void)layoutSubviews [self setupAppearance]; } +- (void)popAtView:(UIView *)view { + [self popAtView:view animated:YES]; +} -- (void)popAtView:(UIView *)view +- (void)popAtView:(UIView *)view animated: (BOOL) animated { if (self.hidden == NO) return; @@ -212,26 +215,32 @@ - (void)popAtView:(UIView *)view _viewCenter = CGPointMake(view.center.x - self.frame.origin.x - 8, view.center.y); [self setNeedsDisplay]; - self.transform = CGAffineTransformMakeScale(0, 0); - view.transform = CGAffineTransformMakeScale(0, 0); - [UIView animateKeyframesWithDuration:duration/6.0f delay:delay options:0 animations:^{ - self.center = centerPoint; - self.alpha = 1.0f; - self.transform = CGAffineTransformMakeScale(1.2, 1.2); - view.transform = CGAffineTransformMakeScale(1.2, 1.2); - } completion:^(BOOL finished) { - [UIView animateKeyframesWithDuration:duration/6.0f delay:0 options:0 animations:^{ - self.transform = CGAffineTransformMakeScale(0.9, 0.9); - view.transform = CGAffineTransformMakeScale(0.9, 0.9); + if (animated) { + self.transform = CGAffineTransformMakeScale(0, 0); + view.transform = CGAffineTransformMakeScale(0, 0); + + [UIView animateKeyframesWithDuration:duration/6.0f delay:delay options:0 animations:^{ + self.center = centerPoint; + self.alpha = 1.0f; + self.transform = CGAffineTransformMakeScale(1.2, 1.2); + view.transform = CGAffineTransformMakeScale(1.2, 1.2); } completion:^(BOOL finished) { [UIView animateKeyframesWithDuration:duration/6.0f delay:0 options:0 animations:^{ - self.transform = CGAffineTransformMakeScale(1, 1); - view.transform = CGAffineTransformMakeScale(1, 1); + self.transform = CGAffineTransformMakeScale(0.9, 0.9); + view.transform = CGAffineTransformMakeScale(0.9, 0.9); } completion:^(BOOL finished) { - // completion block empty? + [UIView animateKeyframesWithDuration:duration/6.0f delay:0 options:0 animations:^{ + self.transform = CGAffineTransformMakeScale(1, 1); + view.transform = CGAffineTransformMakeScale(1, 1); + } completion:^(BOOL finished) { + // completion block empty? + }]; }]; }]; - }]; + } else { + self.center = centerPoint; + self.alpha = 1.0f; + } } From 357eca318d3d498ff7809178f8a35ede3ed2e892 Mon Sep 17 00:00:00 2001 From: Lucas Vidal Date: Wed, 11 Feb 2015 12:45:42 -0300 Subject: [PATCH 02/22] bump version --- MMPopLabel.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MMPopLabel.podspec b/MMPopLabel.podspec index d264ac9..69224a6 100644 --- a/MMPopLabel.podspec +++ b/MMPopLabel.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "MMPopLabel" - s.version = "0.1.1" + s.version = "0.1.2" s.summary = "MMPopLabel is a tooltip control for iOS, with optional buttons" s.description = <<-DESC MMPopLabel is a tooltip control for iOS, useful for tutorials. From ab0acd8ec6cb7207e51be647ffa86ce1dae9b015 Mon Sep 17 00:00:00 2001 From: Lucas Vidal Date: Thu, 12 Feb 2015 18:27:10 -0300 Subject: [PATCH 03/22] Allow initializing popup with attributed string --- Classes/ios/MMPopLabel.h | 2 ++ Classes/ios/MMPopLabel.m | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/Classes/ios/MMPopLabel.h b/Classes/ios/MMPopLabel.h index f3bdcb2..0d738da 100644 --- a/Classes/ios/MMPopLabel.h +++ b/Classes/ios/MMPopLabel.h @@ -25,6 +25,8 @@ @property (nonatomic, weak) id delegate; ++ (MMPopLabel *)popLabelWithAttributedString:(NSAttributedString *)attributedString; + + (MMPopLabel *)popLabelWithText:(NSString *)text; - (void)addButton:(UIButton *)button; diff --git a/Classes/ios/MMPopLabel.m b/Classes/ios/MMPopLabel.m index df8199d..580994b 100644 --- a/Classes/ios/MMPopLabel.m +++ b/Classes/ios/MMPopLabel.m @@ -51,6 +51,13 @@ @interface MMPopLabel () @implementation MMPopLabel ++ (MMPopLabel *)popLabelWithAttributedString:(NSAttributedString *)attributedString { + MMPopLabel *popLabel = [[MMPopLabel alloc] initWithAttributedString: attributedString]; + + + return popLabel; + +} + (MMPopLabel *)popLabelWithText:(NSString *)text { @@ -59,6 +66,30 @@ + (MMPopLabel *)popLabelWithText:(NSString *)text return popLabel; } +- (instancetype)initWithAttributedString: (NSAttributedString *)attributedString { + if (self = [super initWithFrame:CGRectZero]) + { + self.buttons = [@[] mutableCopy]; + + self.backgroundColor = [UIColor clearColor]; + self.hidden = YES; + + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { + self.tipSize = 24; + } else { + self.tipSize = 12; + } + + self.label = [[MMLabel alloc] initWithFrame:CGRectZero]; + self.label.textAlignment = NSTextAlignmentCenter; + self.label.attributedText = attributedString; + self.label.backgroundColor = [UIColor clearColor]; + self.label.numberOfLines = 0; + + [self addSubview:self.label]; + } + return self; +} - (id)initWithText:(NSString *)text { From 02e39655e46c27dc4383e52feb96a66b2e9bc132 Mon Sep 17 00:00:00 2001 From: Lucas Vidal Date: Thu, 12 Feb 2015 18:29:17 -0300 Subject: [PATCH 04/22] bump version --- MMPopLabel.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MMPopLabel.podspec b/MMPopLabel.podspec index 69224a6..48c5006 100644 --- a/MMPopLabel.podspec +++ b/MMPopLabel.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "MMPopLabel" - s.version = "0.1.2" + s.version = "0.1.3" s.summary = "MMPopLabel is a tooltip control for iOS, with optional buttons" s.description = <<-DESC MMPopLabel is a tooltip control for iOS, useful for tutorials. From 912897fbf88a8a38b7fb29f90edd1cf282d6c39a Mon Sep 17 00:00:00 2001 From: Lucas Vidal Date: Thu, 12 Feb 2015 19:52:45 -0300 Subject: [PATCH 05/22] Arrow is now a triangle --- Classes/ios/MMPopLabel.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Classes/ios/MMPopLabel.m b/Classes/ios/MMPopLabel.m index 580994b..653233e 100644 --- a/Classes/ios/MMPopLabel.m +++ b/Classes/ios/MMPopLabel.m @@ -308,10 +308,10 @@ - (void)drawRect:(CGRect)rect } CGContextRotateCTM(context, -45 * M_PI / 180); - UIBezierPath* tipPath = [UIBezierPath bezierPathWithRect: CGRectMake(0, 0, 11, 11)]; - [_labelColor setFill]; - [tipPath fill]; - +// UIBezierPath* tipPath = [UIBezierPath bezierPathWithRect: CGRectMake(0, 0, 11, 11)]; +// [_labelColor setFill]; +// [tipPath fill]; + CGContextRestoreGState(context); //// ViewBackground Drawing From 994fd1068dcaecb66f54ce68429382f93646d7d0 Mon Sep 17 00:00:00 2001 From: Lucas Vidal Date: Thu, 19 Feb 2015 17:28:40 -0300 Subject: [PATCH 06/22] Update MMPopLabel.m --- Classes/ios/MMPopLabel.m | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Classes/ios/MMPopLabel.m b/Classes/ios/MMPopLabel.m index 653233e..343c74f 100644 --- a/Classes/ios/MMPopLabel.m +++ b/Classes/ios/MMPopLabel.m @@ -308,10 +308,13 @@ - (void)drawRect:(CGRect)rect } CGContextRotateCTM(context, -45 * M_PI / 180); -// UIBezierPath* tipPath = [UIBezierPath bezierPathWithRect: CGRectMake(0, 0, 11, 11)]; -// [_labelColor setFill]; -// [tipPath fill]; - + UIBezierPath *tipPath = [UIBezierPath bezierPath]; + [tipPath moveToPoint:CGPointMake( 0, 0)]; + [tipPath addLineToPoint:CGPointMake(0, 11)]; + [tipPath addLineToPoint:CGPointMake(11, 11)]; + [tipPath addLineToPoint:CGPointMake( 0, 0)]; + [tipPath closePath]; + CGContextRestoreGState(context); //// ViewBackground Drawing From 17dfe8faac9c76dabefaa8b8744c015c8c3587bc Mon Sep 17 00:00:00 2001 From: Lucas Vidal Date: Thu, 19 Feb 2015 17:48:38 -0300 Subject: [PATCH 07/22] Update MMPopLabel.podspec bump version --- MMPopLabel.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MMPopLabel.podspec b/MMPopLabel.podspec index 48c5006..34c3eb6 100644 --- a/MMPopLabel.podspec +++ b/MMPopLabel.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "MMPopLabel" - s.version = "0.1.3" + s.version = "0.1.4" s.summary = "MMPopLabel is a tooltip control for iOS, with optional buttons" s.description = <<-DESC MMPopLabel is a tooltip control for iOS, useful for tutorials. From 56c6be8772eeb5e239cc5bde98a5229b716e4782 Mon Sep 17 00:00:00 2001 From: Lucas Vidal Date: Fri, 20 Feb 2015 11:44:48 -0300 Subject: [PATCH 08/22] Update MMPopLabel.m --- Classes/ios/MMPopLabel.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Classes/ios/MMPopLabel.m b/Classes/ios/MMPopLabel.m index 343c74f..60a9e6b 100644 --- a/Classes/ios/MMPopLabel.m +++ b/Classes/ios/MMPopLabel.m @@ -315,6 +315,8 @@ - (void)drawRect:(CGRect)rect [tipPath addLineToPoint:CGPointMake( 0, 0)]; [tipPath closePath]; + [_labelColor setFill]; + [tipPath fill]; CGContextRestoreGState(context); //// ViewBackground Drawing From 6423b929554ca70ce2901af7a648268416bfb364 Mon Sep 17 00:00:00 2001 From: Gabriel Dario Ros Date: Tue, 17 Mar 2015 18:52:08 -0300 Subject: [PATCH 09/22] Horrible hack, reading this will cost some sanity points. --- Classes/ios/MMPopLabel.m | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Classes/ios/MMPopLabel.m b/Classes/ios/MMPopLabel.m index 60a9e6b..2e4c050 100644 --- a/Classes/ios/MMPopLabel.m +++ b/Classes/ios/MMPopLabel.m @@ -208,6 +208,17 @@ - (void)layoutSubviews [self setupAppearance]; } +//HORRIBLE HORRIBLE HACK !!! +- (CGFloat)tabBarHeight +{ + UITabBar *tabBar; + UIViewController *rootVC = [[[UIApplication sharedApplication] keyWindow] rootViewController]; + if ([rootVC isKindOfClass:[UITabBarController class]]) { + tabBar = [((UITabBarController *) rootVC) tabBar]; + } + return tabBar != nil ? tabBar.frame.size.height : 0; +} + - (void)popAtView:(UIView *)view { [self popAtView:view animated:YES]; } @@ -231,7 +242,7 @@ - (void)popAtView:(UIView *)view animated: (BOOL) animated if (self.frame.origin.y + self.frame.size.height > [UIScreen mainScreen].applicationFrame.size.height) { _arrowType = MMPopLabelBottomArrow; position = CGPointMake(position.x, - [UIScreen mainScreen].applicationFrame.size.height - (self.frame.size.height + view.frame.size.height + kMMPopLabelViewPadding)); + [UIScreen mainScreen].applicationFrame.size.height - (self.frame.size.height + view.frame.size.height + kMMPopLabelViewPadding + /*HORRIBLE HACK !!!*/[self tabBarHeight])); } CGPoint centerPoint = CGPointMake(position.x, position.y + self.frame.size.height / 2); From fbcfcc62bfb31ee2f9200a634fccc4e1c8809ab0 Mon Sep 17 00:00:00 2001 From: Gabriel Dario Ros Date: Fri, 20 Mar 2015 12:19:53 -0300 Subject: [PATCH 10/22] Bump version. --- MMPopLabel.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MMPopLabel.podspec b/MMPopLabel.podspec index 34c3eb6..e9bb8fb 100644 --- a/MMPopLabel.podspec +++ b/MMPopLabel.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "MMPopLabel" - s.version = "0.1.4" + s.version = "0.1.5" s.summary = "MMPopLabel is a tooltip control for iOS, with optional buttons" s.description = <<-DESC MMPopLabel is a tooltip control for iOS, useful for tutorials. From 44391d09c9296faa2dd788fbd5373728648b3fd5 Mon Sep 17 00:00:00 2001 From: "Fabian E. Pezet Vila" Date: Tue, 7 Apr 2015 11:10:25 -0300 Subject: [PATCH 11/22] hack to support navigation bar --- Classes/ios/MMPopLabel.m | 16 ++++++++++++++-- MMPopLabel.podspec | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Classes/ios/MMPopLabel.m b/Classes/ios/MMPopLabel.m index 2e4c050..5e3cee7 100644 --- a/Classes/ios/MMPopLabel.m +++ b/Classes/ios/MMPopLabel.m @@ -219,6 +219,17 @@ - (CGFloat)tabBarHeight return tabBar != nil ? tabBar.frame.size.height : 0; } +- (CGFloat)navBarHeight +{ + UIViewController *rootVC = [[[UIApplication sharedApplication] keyWindow] rootViewController]; + if ([rootVC isKindOfClass:[UITabBarController class]]) { + UINavigationController *vc = ((UITabBarController*) rootVC).viewControllers[1]; + return vc.navigationBar.frame.size.height; + } + return 44; +} + + - (void)popAtView:(UIView *)view { [self popAtView:view animated:YES]; } @@ -239,10 +250,11 @@ - (void)popAtView:(UIView *)view animated: (BOOL) animated position = CGPointMake(view.center.x + diff, view.center.y + view.frame.size.height / 2); } - if (self.frame.origin.y + self.frame.size.height > [UIScreen mainScreen].applicationFrame.size.height) { + if (self.frame.origin.y + self.frame.size.height > [UIScreen mainScreen].applicationFrame.size.height) - [self navBarHeight] { + _arrowType = MMPopLabelBottomArrow; position = CGPointMake(position.x, - [UIScreen mainScreen].applicationFrame.size.height - (self.frame.size.height + view.frame.size.height + kMMPopLabelViewPadding + /*HORRIBLE HACK !!!*/[self tabBarHeight])); + [UIScreen mainScreen].applicationFrame.size.height - (self.frame.size.height + view.frame.size.height + kMMPopLabelViewPadding + /*HORRIBLE HACK !!!*/[self tabBarHeight] + [self navBarHeight])); } CGPoint centerPoint = CGPointMake(position.x, position.y + self.frame.size.height / 2); diff --git a/MMPopLabel.podspec b/MMPopLabel.podspec index e9bb8fb..a87f793 100644 --- a/MMPopLabel.podspec +++ b/MMPopLabel.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "MMPopLabel" - s.version = "0.1.5" + s.version = "0.1.6" s.summary = "MMPopLabel is a tooltip control for iOS, with optional buttons" s.description = <<-DESC MMPopLabel is a tooltip control for iOS, useful for tutorials. From ebd8bc622622837510b70c52b020741cff2f2943 Mon Sep 17 00:00:00 2001 From: "Fabian E. Pezet Vila" Date: Tue, 7 Apr 2015 12:18:50 -0300 Subject: [PATCH 12/22] fix bug in if --- Classes/ios/MMPopLabel.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/ios/MMPopLabel.m b/Classes/ios/MMPopLabel.m index 5e3cee7..d776dcb 100644 --- a/Classes/ios/MMPopLabel.m +++ b/Classes/ios/MMPopLabel.m @@ -250,7 +250,7 @@ - (void)popAtView:(UIView *)view animated: (BOOL) animated position = CGPointMake(view.center.x + diff, view.center.y + view.frame.size.height / 2); } - if (self.frame.origin.y + self.frame.size.height > [UIScreen mainScreen].applicationFrame.size.height) - [self navBarHeight] { + if (self.frame.origin.y + self.frame.size.height > ([UIScreen mainScreen].applicationFrame.size.height) - [self navBarHeight]) { _arrowType = MMPopLabelBottomArrow; position = CGPointMake(position.x, From b6171353bfe88fbb98f7a7e45bfb5690c1a86744 Mon Sep 17 00:00:00 2001 From: "Fabian E. Pezet Vila" Date: Tue, 7 Apr 2015 14:57:43 -0300 Subject: [PATCH 13/22] remove dismiss popup when pressed over it --- Classes/ios/MMPopLabel.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/ios/MMPopLabel.m b/Classes/ios/MMPopLabel.m index d776dcb..c10f408 100644 --- a/Classes/ios/MMPopLabel.m +++ b/Classes/ios/MMPopLabel.m @@ -300,7 +300,7 @@ - (void)popAtView:(UIView *)view animated: (BOOL) animated - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { - [self dismiss]; + } From 65f87c9a5a9534e116e7840a5be625d88567bf0a Mon Sep 17 00:00:00 2001 From: "Fabian E. Pezet Vila" Date: Tue, 7 Apr 2015 15:22:42 -0300 Subject: [PATCH 14/22] increase kMMPopLabelViewPadding to 8 --- Classes/ios/MMPopLabel.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/ios/MMPopLabel.m b/Classes/ios/MMPopLabel.m index c10f408..b72980c 100644 --- a/Classes/ios/MMPopLabel.m +++ b/Classes/ios/MMPopLabel.m @@ -15,7 +15,7 @@ CGFloat const kMMPopLabelSidePadding = 10.0f; -CGFloat const kMMPopLabelViewPadding = 2.0f; +CGFloat const kMMPopLabelViewPadding = 8.0f; CGFloat const kMMPopLabelCornerRadius = 6.0f; CGFloat const kMMPopLabelTipPadding = 8.0f; From 234903ed0b5f811a10baeb312cbab095efe295d9 Mon Sep 17 00:00:00 2001 From: "Fabian E. Pezet Vila" Date: Tue, 7 Apr 2015 15:35:48 -0300 Subject: [PATCH 15/22] change font type for OK button --- Classes/ios/MMPopLabel.m | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Classes/ios/MMPopLabel.m b/Classes/ios/MMPopLabel.m index b72980c..7500921 100644 --- a/Classes/ios/MMPopLabel.m +++ b/Classes/ios/MMPopLabel.m @@ -180,11 +180,7 @@ - (void)setupAppearance self.bounds.origin.y + self.bounds.size.height - 44, buttonWidth, 33); - if (_buttonFont) { - b.titleLabel.font = _buttonFont; - } else { - b.titleLabel.font = [UIFont systemFontOfSize:_tipSize]; - } + b.titleLabel.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:15.0]; [b setTitleColor:_labelTextColor forState:UIControlStateNormal]; [b setTitleColor:_labelTextHighlightColor forState:UIControlStateHighlighted]; From 2b58cd7c93ca6084220ef5438dd724d6000cbc8c Mon Sep 17 00:00:00 2001 From: "Fabian E. Pezet Vila" Date: Tue, 7 Apr 2015 15:43:31 -0300 Subject: [PATCH 16/22] move back 1 commit./ --- Classes/ios/MMPopLabel.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Classes/ios/MMPopLabel.m b/Classes/ios/MMPopLabel.m index 7500921..b72980c 100644 --- a/Classes/ios/MMPopLabel.m +++ b/Classes/ios/MMPopLabel.m @@ -180,7 +180,11 @@ - (void)setupAppearance self.bounds.origin.y + self.bounds.size.height - 44, buttonWidth, 33); - b.titleLabel.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:15.0]; + if (_buttonFont) { + b.titleLabel.font = _buttonFont; + } else { + b.titleLabel.font = [UIFont systemFontOfSize:_tipSize]; + } [b setTitleColor:_labelTextColor forState:UIControlStateNormal]; [b setTitleColor:_labelTextHighlightColor forState:UIControlStateHighlighted]; From 0c6562059b5fc8766104d87b810988f7499612c4 Mon Sep 17 00:00:00 2001 From: "Fabian E. Pezet Vila" Date: Mon, 20 Apr 2015 14:33:22 -0300 Subject: [PATCH 17/22] change place where setup the appearance. --- Classes/ios/MMPopLabel.m | 9 ++------- MMPopLabel.podspec | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/Classes/ios/MMPopLabel.m b/Classes/ios/MMPopLabel.m index b72980c..c583f02 100644 --- a/Classes/ios/MMPopLabel.m +++ b/Classes/ios/MMPopLabel.m @@ -201,13 +201,6 @@ - (void)addButton:(UIButton *)button [self.buttons addObject:button]; } - -- (void)layoutSubviews -{ - [super layoutSubviews]; - [self setupAppearance]; -} - //HORRIBLE HORRIBLE HACK !!! - (CGFloat)tabBarHeight { @@ -238,6 +231,8 @@ - (void)popAtView:(UIView *)view animated: (BOOL) animated { if (self.hidden == NO) return; + [self setupAppearance]; + _arrowType = MMPopLabelTopArrow; CGPoint position = CGPointMake(view.center.x, view.center.y + view.frame.size.height / 2 + kMMPopLabelViewPadding); diff --git a/MMPopLabel.podspec b/MMPopLabel.podspec index a87f793..76405b8 100644 --- a/MMPopLabel.podspec +++ b/MMPopLabel.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "MMPopLabel" - s.version = "0.1.6" + s.version = “0.1.7” s.summary = "MMPopLabel is a tooltip control for iOS, with optional buttons" s.description = <<-DESC MMPopLabel is a tooltip control for iOS, useful for tutorials. From 16a27a62bfc3df0f97dad25f5d49514e7dca62ac Mon Sep 17 00:00:00 2001 From: "Fabian E. Pezet Vila" Date: Mon, 20 Apr 2015 14:47:21 -0300 Subject: [PATCH 18/22] fix problem with char type --- MMPopLabel.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MMPopLabel.podspec b/MMPopLabel.podspec index 76405b8..3423470 100644 --- a/MMPopLabel.podspec +++ b/MMPopLabel.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "MMPopLabel" - s.version = “0.1.7” + s.version = "0.1.7" s.summary = "MMPopLabel is a tooltip control for iOS, with optional buttons" s.description = <<-DESC MMPopLabel is a tooltip control for iOS, useful for tutorials. From 1fcd6c9098d7031a3928f1c1b6d0d1a3292af57e Mon Sep 17 00:00:00 2001 From: Lucas Vidal Date: Tue, 21 Apr 2015 14:47:02 -0300 Subject: [PATCH 19/22] apply fix patch --- Classes/ios/MMPopLabel.m | 73 +++++++++++++++------------------------- 1 file changed, 28 insertions(+), 45 deletions(-) diff --git a/Classes/ios/MMPopLabel.m b/Classes/ios/MMPopLabel.m index c583f02..71989b9 100644 --- a/Classes/ios/MMPopLabel.m +++ b/Classes/ios/MMPopLabel.m @@ -53,16 +53,16 @@ @implementation MMPopLabel + (MMPopLabel *)popLabelWithAttributedString:(NSAttributedString *)attributedString { MMPopLabel *popLabel = [[MMPopLabel alloc] initWithAttributedString: attributedString]; - - + + return popLabel; - + } + (MMPopLabel *)popLabelWithText:(NSString *)text { MMPopLabel *popLabel = [[MMPopLabel alloc] initWithText:text]; - + return popLabel; } @@ -70,22 +70,22 @@ - (instancetype)initWithAttributedString: (NSAttributedString *)attributedString if (self = [super initWithFrame:CGRectZero]) { self.buttons = [@[] mutableCopy]; - + self.backgroundColor = [UIColor clearColor]; self.hidden = YES; - + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { self.tipSize = 24; } else { self.tipSize = 12; } - + self.label = [[MMLabel alloc] initWithFrame:CGRectZero]; self.label.textAlignment = NSTextAlignmentCenter; self.label.attributedText = attributedString; self.label.backgroundColor = [UIColor clearColor]; self.label.numberOfLines = 0; - + [self addSubview:self.label]; } return self; @@ -99,13 +99,13 @@ - (id)initWithText:(NSString *)text self.backgroundColor = [UIColor clearColor]; self.hidden = YES; - + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { self.tipSize = 24; } else { self.tipSize = 12; } - + self.label = [[MMLabel alloc] initWithFrame:CGRectZero]; self.label.textAlignment = NSTextAlignmentCenter; self.label.text = text; @@ -139,11 +139,11 @@ - (void)setupAppearance self.label.textColor = _labelTextColor; self.label.font = _labelFont; - + /* resize label and view */ CGFloat maxWidth = [UIScreen mainScreen].applicationFrame.size.width * 0.80f; CGFloat maxHeight = [UIScreen mainScreen].applicationFrame.size.height * 0.80f; - + NSAttributedString *attributedText = [[NSAttributedString alloc] initWithString:self.label.text attributes:@{NSFontAttributeName:_labelFont}]; CGRect rect = [attributedText boundingRectWithSize:(CGSize){maxWidth, CGFLOAT_MAX} @@ -151,7 +151,7 @@ - (void)setupAppearance context:nil]; CGFloat minWidth = MAX(rect.size.width, 180); CGFloat minHeight = MIN(rect.size.height, maxHeight); - + self.label.frame = CGRectMake(0, 0, minWidth, minHeight); [self.label sizeToFit]; @@ -163,7 +163,7 @@ - (void)setupAppearance self.label.frame = CGRectMake(_targetFrame.origin.x, _targetFrame.origin.y, minWidth, _targetFrame.size.height + _tipSize * 4); - + /* add buttons, if any */ if (_buttons.count == 0) return; @@ -171,7 +171,7 @@ - (void)setupAppearance self.frame.origin.y, self.frame.size.width, self.frame.size.height + 33); - + NSInteger index = 0; NSInteger buttonWidth = self.frame.size.width / _buttons.count; for (UIButton *b in _buttons) { @@ -179,13 +179,13 @@ - (void)setupAppearance b.frame = CGRectMake(self.bounds.origin.x + (index * buttonWidth), self.bounds.origin.y + self.bounds.size.height - 44, buttonWidth, 33); - + if (_buttonFont) { b.titleLabel.font = _buttonFont; } else { b.titleLabel.font = [UIFont systemFontOfSize:_tipSize]; } - + [b setTitleColor:_labelTextColor forState:UIControlStateNormal]; [b setTitleColor:_labelTextHighlightColor forState:UIControlStateHighlighted]; @@ -201,28 +201,13 @@ - (void)addButton:(UIButton *)button [self.buttons addObject:button]; } -//HORRIBLE HORRIBLE HACK !!! -- (CGFloat)tabBarHeight -{ - UITabBar *tabBar; - UIViewController *rootVC = [[[UIApplication sharedApplication] keyWindow] rootViewController]; - if ([rootVC isKindOfClass:[UITabBarController class]]) { - tabBar = [((UITabBarController *) rootVC) tabBar]; - } - return tabBar != nil ? tabBar.frame.size.height : 0; -} -- (CGFloat)navBarHeight +- (void)layoutSubviews { - UIViewController *rootVC = [[[UIApplication sharedApplication] keyWindow] rootViewController]; - if ([rootVC isKindOfClass:[UITabBarController class]]) { - UINavigationController *vc = ((UITabBarController*) rootVC).viewControllers[1]; - return vc.navigationBar.frame.size.height; - } - return 44; + [super layoutSubviews]; + [self setupAppearance]; } - - (void)popAtView:(UIView *)view { [self popAtView:view animated:YES]; } @@ -230,11 +215,9 @@ - (void)popAtView:(UIView *)view { - (void)popAtView:(UIView *)view animated: (BOOL) animated { if (self.hidden == NO) return; - - [self setupAppearance]; _arrowType = MMPopLabelTopArrow; - + CGPoint position = CGPointMake(view.center.x, view.center.y + view.frame.size.height / 2 + kMMPopLabelViewPadding); self.center = position; if (position.x + (self.frame.size.width / 2) > [UIScreen mainScreen].applicationFrame.size.width) { @@ -245,13 +228,13 @@ - (void)popAtView:(UIView *)view animated: (BOOL) animated position = CGPointMake(view.center.x + diff, view.center.y + view.frame.size.height / 2); } - if (self.frame.origin.y + self.frame.size.height > ([UIScreen mainScreen].applicationFrame.size.height) - [self navBarHeight]) { + if (self.frame.origin.y + self.frame.size.height > [[self superview] frame].size.height) { _arrowType = MMPopLabelBottomArrow; position = CGPointMake(position.x, - [UIScreen mainScreen].applicationFrame.size.height - (self.frame.size.height + view.frame.size.height + kMMPopLabelViewPadding + /*HORRIBLE HACK !!!*/[self tabBarHeight] + [self navBarHeight])); + [[self superview] frame].size.height - (self.frame.size.height + view.frame.size.height + kMMPopLabelViewPadding)); } - + CGPoint centerPoint = CGPointMake(position.x, position.y + self.frame.size.height / 2); self.center = position; @@ -267,7 +250,7 @@ - (void)popAtView:(UIView *)view animated: (BOOL) animated if (animated) { self.transform = CGAffineTransformMakeScale(0, 0); view.transform = CGAffineTransformMakeScale(0, 0); - + [UIView animateKeyframesWithDuration:duration/6.0f delay:delay options:0 animations:^{ self.center = centerPoint; self.alpha = 1.0f; @@ -295,14 +278,14 @@ - (void)popAtView:(UIView *)view animated: (BOOL) animated - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { - + } - (void)dismiss { if (self.hidden == YES) return; - + [UIView animateWithDuration:0.15f animations:^{ self.alpha = 0.0f; } completion:^(BOOL finished) { @@ -333,7 +316,7 @@ - (void)drawRect:(CGRect)rect [tipPath addLineToPoint:CGPointMake( 0, 0)]; [tipPath closePath]; - [_labelColor setFill]; + [[UIColor redColor] setFill]; [tipPath fill]; CGContextRestoreGState(context); From 8c3404cce531cc42bfe398a996f24d3356360f07 Mon Sep 17 00:00:00 2001 From: Lucas Vidal Date: Tue, 21 Apr 2015 16:57:30 -0300 Subject: [PATCH 20/22] restore color --- Classes/ios/MMPopLabel.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/ios/MMPopLabel.m b/Classes/ios/MMPopLabel.m index 71989b9..c0ac0d2 100644 --- a/Classes/ios/MMPopLabel.m +++ b/Classes/ios/MMPopLabel.m @@ -316,7 +316,7 @@ - (void)drawRect:(CGRect)rect [tipPath addLineToPoint:CGPointMake( 0, 0)]; [tipPath closePath]; - [[UIColor redColor] setFill]; + [_labelColor setFill]; [tipPath fill]; CGContextRestoreGState(context); From 86a86eeb0073cc1c0ecef33877ee89057248fa41 Mon Sep 17 00:00:00 2001 From: Lucas Vidal Date: Tue, 21 Apr 2015 17:02:06 -0300 Subject: [PATCH 21/22] version bump --- MMPopLabel.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MMPopLabel.podspec b/MMPopLabel.podspec index 3423470..bbe822f 100644 --- a/MMPopLabel.podspec +++ b/MMPopLabel.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "MMPopLabel" - s.version = "0.1.7" + s.version = "0.1.8" s.summary = "MMPopLabel is a tooltip control for iOS, with optional buttons" s.description = <<-DESC MMPopLabel is a tooltip control for iOS, useful for tutorials. From 8845aae8d3696814a500dad41c79a0dde8c48a5d Mon Sep 17 00:00:00 2001 From: Lucas Vidal Date: Wed, 22 Apr 2015 12:24:27 -0300 Subject: [PATCH 22/22] add text setter --- Classes/ios/MMPopLabel.h | 1 + Classes/ios/MMPopLabel.m | 3 +++ MMPopLabel.podspec | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Classes/ios/MMPopLabel.h b/Classes/ios/MMPopLabel.h index 0d738da..baf64f7 100644 --- a/Classes/ios/MMPopLabel.h +++ b/Classes/ios/MMPopLabel.h @@ -36,6 +36,7 @@ //will use animations by default - (void)popAtView:(UIView *)view; +- (void)setText: (NSString *)text; - (void)dismiss; diff --git a/Classes/ios/MMPopLabel.m b/Classes/ios/MMPopLabel.m index c0ac0d2..71d0e0b 100644 --- a/Classes/ios/MMPopLabel.m +++ b/Classes/ios/MMPopLabel.m @@ -117,6 +117,9 @@ - (id)initWithText:(NSString *)text return self; } +- (void)setText: (NSString *)text { + self.label.text = text; +} - (void)setupAppearance { diff --git a/MMPopLabel.podspec b/MMPopLabel.podspec index bbe822f..777c72a 100644 --- a/MMPopLabel.podspec +++ b/MMPopLabel.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "MMPopLabel" - s.version = "0.1.8" + s.version = "0.1.9" s.summary = "MMPopLabel is a tooltip control for iOS, with optional buttons" s.description = <<-DESC MMPopLabel is a tooltip control for iOS, useful for tutorials.