Skip to content
This repository was archived by the owner on Jul 17, 2024. It is now read-only.

small update #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
35 changes: 20 additions & 15 deletions Classes/ios/MMPopLabel.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
typedef enum : NSUInteger {
MMPopLabelTopArrow,
MMPopLabelBottomArrow,
MMPopLabelNoArrow
} MMPopLabelArrowType;


Expand Down Expand Up @@ -227,7 +228,7 @@ - (void)popAtView:(UIView *)view
position = CGPointMake(position.x, center.y + self.frame.size.height / 2 + view.frame.size.height / 2 + kMMPopLabelViewPadding);
}

CGPoint centerPoint = CGPointMake(position.x, position.y);
CGPoint centerPoint = CGPointMake(position.x, position.y);
self.center = position;

_viewCenter = CGPointMake(view.center.x - self.frame.origin.x - 8, view.center.y);
Expand Down Expand Up @@ -306,7 +307,9 @@ - (void)dismiss
self.alpha = 0.0f;
} completion:^(BOOL finished) {
self.hidden = YES;
[_delegate dismissedPopLabel:self];
if (_delegate && [_delegate respondsToSelector: @selector(dismissedPopLabel:)]){
[_delegate dismissedPopLabel:self];
}
}];
}

Expand All @@ -315,19 +318,22 @@ - (void)drawRect:(CGRect)rect
{
//// General Declarations
CGContextRef context = UIGraphicsGetCurrentContext();

[_labelColor setFill];

//// Tip Drawing
CGContextSaveGState(context);
if (_arrowType == MMPopLabelBottomArrow) {
CGContextTranslateCTM(context, _viewCenter.x, rect.size.height - kMMPopLabelTipPadding);
} else if (_arrowType == MMPopLabelTopArrow) {
CGContextTranslateCTM(context, _viewCenter.x, kMMPopLabelTipPadding);
}
CGContextRotateCTM(context, -45 * M_PI / 180);
if (_arrowType != MMPopLabelNoArrow) {
CGContextSaveGState(context);
if (_arrowType == MMPopLabelBottomArrow) {
CGContextTranslateCTM(context, _viewCenter.x, rect.size.height - kMMPopLabelTipPadding);
} else if (_arrowType == MMPopLabelTopArrow) {
CGContextTranslateCTM(context, _viewCenter.x, kMMPopLabelTipPadding);
}
CGContextRotateCTM(context, -45 * M_PI / 180);

UIBezierPath* tipPath = [UIBezierPath bezierPathWithRect: CGRectMake(0, 0, 11, 11)];
[_labelColor setFill];
[tipPath fill];
[[UIBezierPath bezierPathWithRect: CGRectMake(0, 0, 11, 11)] fill];

CGContextRestoreGState(context);
}

CGContextRestoreGState(context);

Expand All @@ -337,7 +343,6 @@ - (void)drawRect:(CGRect)rect
rect.size.width,
rect.size.height - kMMPopLabelTipPadding * 2)
cornerRadius:kMMPopLabelCornerRadius];
[_labelColor setFill];
[viewBackgroundPath fill];
}

Expand All @@ -350,7 +355,7 @@ - (void)drawRect:(CGRect)rect
- (void)buttonPressed:(id)sender
{
UIButton *button = (UIButton *)sender;
if (_delegate != nil) {
if (_delegate && [_delegate respondsToSelector: @selector(didPressButtonForPopLabel:atIndex:)]) {
[_delegate didPressButtonForPopLabel:self atIndex:button.tag];
}
[self dismiss];
Expand Down