Skip to content
This repository was archived by the owner on Jul 17, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Classes/ios/MMPopLabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
13 changes: 10 additions & 3 deletions Classes/ios/MMPopLabel.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@
<string>MMPopLabelDemo</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>7F1214F5-E122-499B-B1ED-43727EDC081B</key>
<string>ssh://github.com/mgcm/MMPopLabel.git</string>
<key>E09C3556548B7DEF49A277E2CFBC14BD012CDDA8</key>
<string>https://github.com/oflannabhra/MMPopLabel.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>Example/MMPopLabelDemo.xcodeproj/project.xcworkspace</string>
<string>Example/MMPopLabelDemo.xcodeproj</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>7F1214F5-E122-499B-B1ED-43727EDC081B</key>
<key>E09C3556548B7DEF49A277E2CFBC14BD012CDDA8</key>
<string>../../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>ssh://github.com/mgcm/MMPopLabel.git</string>
<string>https://github.com/oflannabhra/MMPopLabel.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>110</integer>
<integer>111</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>7F1214F5-E122-499B-B1ED-43727EDC081B</string>
<string>E09C3556548B7DEF49A277E2CFBC14BD012CDDA8</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>7F1214F5-E122-499B-B1ED-43727EDC081B</string>
<string>E09C3556548B7DEF49A277E2CFBC14BD012CDDA8</string>
<key>IDESourceControlWCCName</key>
<string>MMPopLabel</string>
</dict>
Expand Down
18 changes: 16 additions & 2 deletions Example/MMPopLabelDemo/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6254" systemVersion="14C109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="vXZ-lx-hvc">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7531" systemVersion="14D131" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="vXZ-lx-hvc">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7520"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
</dependencies>
<scenes>
Expand Down Expand Up @@ -90,6 +90,16 @@
<action selector="topPressed:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="9Hp-9X-esp"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="PGw-Cr-1lF">
<rect key="frame" x="20" y="307" width="280" height="30"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="nSE-G7-XVV"/>
</constraints>
<state key="normal" title="Show Timed Popup"/>
<connections>
<action selector="timerButtonPressed:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="O8j-kA-vS7"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
Expand All @@ -98,12 +108,15 @@
<constraint firstItem="moA-9g-du6" firstAttribute="top" secondItem="5yF-4i-oSQ" secondAttribute="bottom" id="FNK-1q-NU6"/>
<constraint firstItem="moA-9g-du6" firstAttribute="leading" secondItem="kh9-bI-dsS" secondAttribute="leadingMargin" id="GHP-YX-Wuy"/>
<constraint firstAttribute="centerY" secondItem="J8p-GK-y4j" secondAttribute="centerY" id="GKx-qw-xA2"/>
<constraint firstAttribute="trailingMargin" secondItem="PGw-Cr-1lF" secondAttribute="trailing" constant="4" id="LP1-Bz-VdQ"/>
<constraint firstAttribute="trailing" secondItem="SNu-1e-B5c" secondAttribute="trailing" constant="16" id="UgB-IW-w8X"/>
<constraint firstAttribute="centerX" secondItem="J8p-GK-y4j" secondAttribute="centerX" id="X0S-Le-gwT"/>
<constraint firstAttribute="trailing" secondItem="KFi-bs-gwM" secondAttribute="trailing" id="XU1-tZ-9Pe"/>
<constraint firstItem="noO-fc-ps1" firstAttribute="top" secondItem="KFi-bs-gwM" secondAttribute="bottom" id="XZr-bZ-yU6"/>
<constraint firstItem="PGw-Cr-1lF" firstAttribute="leading" secondItem="kh9-bI-dsS" secondAttribute="leadingMargin" constant="4" id="bj1-Ys-UNH"/>
<constraint firstAttribute="trailingMargin" secondItem="J8p-GK-y4j" secondAttribute="trailing" constant="4" id="jn0-OF-Sk8"/>
<constraint firstItem="KFi-bs-gwM" firstAttribute="top" secondItem="SNu-1e-B5c" secondAttribute="bottom" constant="22" id="mEQ-u9-ZAB"/>
<constraint firstItem="PGw-Cr-1lF" firstAttribute="top" secondItem="J8p-GK-y4j" secondAttribute="bottom" constant="8" id="pCg-PP-PSY"/>
<constraint firstAttribute="trailingMargin" secondItem="2Mw-ez-W0I" secondAttribute="trailing" id="sAU-Po-xVz"/>
<constraint firstItem="KFi-bs-gwM" firstAttribute="leading" secondItem="kh9-bI-dsS" secondAttribute="leading" id="tx9-QI-ouV"/>
<constraint firstItem="3tW-P1-K0O" firstAttribute="leading" secondItem="kh9-bI-dsS" secondAttribute="leadingMargin" id="uH0-sv-zrS"/>
Expand All @@ -116,6 +129,7 @@
<outlet property="bottomLeftButton" destination="3tW-P1-K0O" id="90p-s7-0E8"/>
<outlet property="bottomRightButton" destination="SNu-1e-B5c" id="0DP-2k-fTS"/>
<outlet property="showPopupButton" destination="J8p-GK-y4j" id="XZB-fn-kDc"/>
<outlet property="timerButton" destination="PGw-Cr-1lF" id="6gu-P5-F5n"/>
<outlet property="topButton" destination="2Mw-ez-W0I" id="f4d-6U-Soa"/>
<outlet property="topLeftButton" destination="moA-9g-du6" id="Ctz-oK-OEX"/>
</connections>
Expand Down
6 changes: 6 additions & 0 deletions Example/MMPopLabelDemo/MMViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ @interface MMViewController () <MMPopLabelDelegate>
@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
Expand Down Expand Up @@ -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
{
Expand Down