diff --git a/Classes/ios/MMPopLabel.h b/Classes/ios/MMPopLabel.h index 663e33d..61f9bc0 100644 --- a/Classes/ios/MMPopLabel.h +++ b/Classes/ios/MMPopLabel.h @@ -38,6 +38,7 @@ typedef NS_OPTIONS(NSUInteger, MMPopLabelAnimationOptions) { + (MMPopLabel *)popLabelWithText:(NSString *)text options:(MMPopLabelAnimationOptions)options; - (void)addButton:(UIButton *)button; - (void)popAtView:(UIView *)view; +- (void)popAtView:(UIView *)view withTimeout:(CGFloat)seconds; - (void)popAtBarButtonItem:(UIBarButtonItem *)barButtonItem; - (void)dismiss; diff --git a/Classes/ios/MMPopLabel.m b/Classes/ios/MMPopLabel.m index b45513e..2bbfb94 100644 --- a/Classes/ios/MMPopLabel.m +++ b/Classes/ios/MMPopLabel.m @@ -202,9 +202,9 @@ - (void)popAtView:(UIView *)view if (self.hidden == NO) return; CGPoint center = view.center; - if ([[view superview] superview] != self.window) { - center = [self.window convertPoint:view.center fromView:view]; - } + // if ([[view superview] superview] != self.window) { + // center = [self.window convertPoint:view.center fromView:view]; + // } self.center = center; _arrowType = MMPopLabelTopArrow; @@ -281,6 +281,13 @@ - (void)popAtView:(UIView *)view } +- (void)popAtView:(UIView *)view withTimeout:(CGFloat)seconds +{ + [self popAtView:view]; + [NSTimer scheduledTimerWithTimeInterval:seconds target:self selector:@selector(dismiss) userInfo:nil repeats:NO]; +} + + - (void)popAtBarButtonItem:(UIBarButtonItem *)barButtonItem { UIView *view = [barButtonItem valueForKey:@"view"]; diff --git a/Example/MMPopLabelDemo.xcodeproj/project.xcworkspace/xcshareddata/MMPopLabelDemo.xccheckout b/Example/MMPopLabelDemo.xcodeproj/project.xcworkspace/xcshareddata/MMPopLabelDemo.xccheckout index 921b2dd..c174d42 100644 --- a/Example/MMPopLabelDemo.xcodeproj/project.xcworkspace/xcshareddata/MMPopLabelDemo.xccheckout +++ b/Example/MMPopLabelDemo.xcodeproj/project.xcworkspace/xcshareddata/MMPopLabelDemo.xccheckout @@ -10,29 +10,29 @@ MMPopLabelDemo IDESourceControlProjectOriginsDictionary - 7F1214F5-E122-499B-B1ED-43727EDC081B - ssh://github.com/mgcm/MMPopLabel.git + E09C3556548B7DEF49A277E2CFBC14BD012CDDA8 + https://github.com/oflannabhra/MMPopLabel.git IDESourceControlProjectPath - Example/MMPopLabelDemo.xcodeproj/project.xcworkspace + Example/MMPopLabelDemo.xcodeproj IDESourceControlProjectRelativeInstallPathDictionary - 7F1214F5-E122-499B-B1ED-43727EDC081B + E09C3556548B7DEF49A277E2CFBC14BD012CDDA8 ../../.. IDESourceControlProjectURL - ssh://github.com/mgcm/MMPopLabel.git + https://github.com/oflannabhra/MMPopLabel.git IDESourceControlProjectVersion - 110 + 111 IDESourceControlProjectWCCIdentifier - 7F1214F5-E122-499B-B1ED-43727EDC081B + E09C3556548B7DEF49A277E2CFBC14BD012CDDA8 IDESourceControlProjectWCConfigurations IDESourceControlRepositoryExtensionIdentifierKey public.vcs.git IDESourceControlWCCIdentifierKey - 7F1214F5-E122-499B-B1ED-43727EDC081B + E09C3556548B7DEF49A277E2CFBC14BD012CDDA8 IDESourceControlWCCName MMPopLabel diff --git a/Example/MMPopLabelDemo/Base.lproj/Main.storyboard b/Example/MMPopLabelDemo/Base.lproj/Main.storyboard index 5c0fe8a..91baeb8 100644 --- a/Example/MMPopLabelDemo/Base.lproj/Main.storyboard +++ b/Example/MMPopLabelDemo/Base.lproj/Main.storyboard @@ -1,8 +1,8 @@ - + - + @@ -90,6 +90,16 @@ + @@ -98,12 +108,15 @@ + + + @@ -116,6 +129,7 @@ + diff --git a/Example/MMPopLabelDemo/MMViewController.m b/Example/MMPopLabelDemo/MMViewController.m index 407a865..a556cdd 100644 --- a/Example/MMPopLabelDemo/MMViewController.m +++ b/Example/MMPopLabelDemo/MMViewController.m @@ -23,6 +23,8 @@ @interface MMViewController () @property (weak, nonatomic) IBOutlet UIButton *topLeftButton; @property (weak, nonatomic) IBOutlet UIButton *bottomLeftButton; @property (weak, nonatomic) IBOutlet UIButton *bottomRightButton; +@property (weak, nonatomic) IBOutlet UIButton *timerButton; + @property (nonatomic, retain) MMPopLabel *label; @end @@ -94,6 +96,10 @@ - (IBAction)topLeftButtonPressed:(id)sender { [_label popAtView:_topLeftButton]; } +- (IBAction)timerButtonPressed:(id)sender { + [_label popAtView:_timerButton withTimeout:2.0]; +} + - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {