Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Handle Notification height #28

Merged
merged 2 commits into from

2 participants

@vIiRuS
Collaborator

This PR contains two things.

  1. Fixes #20 and prevents the notifications from overflowing
  2. If underStatusBar is active, it moves the content down by the height of the status bar, so that it appears vertically centered below the statusbar.

Hope everything is okay.

@cruffenach cruffenach merged commit 3ac12be into from
@cruffenach
Owner

Thanks so much @vIiRuS merged it in with a minor tweak to the vertical positioning of the content when showing under a visible status bar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 5 deletions.
  1. +13 −5 CRToast/CRToast.m
View
18 CRToast/CRToast.m
@@ -623,8 +623,11 @@ - (void)layoutSubviews {
[super layoutSubviews];
CGRect bounds = self.bounds;
CGSize imageSize = self.imageView.image.size;
+ CGFloat statusBarOffset = self.toast.underStatusBar ? CRGetStatusBarHeight() : 0;
+ bounds.size.height = CGRectGetHeight(bounds) - statusBarOffset;
+
self.imageView.frame = CGRectMake(0,
- 0,
+ statusBarOffset,
imageSize.width == 0 ?
0 :
CGRectGetHeight(bounds),
@@ -636,7 +639,7 @@ - (void)layoutSubviews {
if (self.toast.subtitleText == nil) {
self.label.frame = CGRectMake(x,
- 0,
+ statusBarOffset,
width,
CGRectGetHeight(bounds));
} else {
@@ -646,22 +649,27 @@ - (void)layoutSubviews {
NSFontAttributeName : self.toast.font
}
context:nil].size.height;
+ if (height > CGRectGetHeight(bounds)) {
+ height = CGRectGetHeight(bounds);
+ }
CGFloat subtitleHeight = [self.toast.subtitleText boundingRectWithSize:CGSizeMake(width, MAXFLOAT)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:@{
NSFontAttributeName : self.toast.subtitleFont
}
context:nil].size.height;
-
+ if ((CGRectGetHeight(bounds) - (height + subtitleHeight)) < 5) {
+ subtitleHeight = (CGRectGetHeight(bounds) - (height))-10;
+ }
CGFloat offset = (CGRectGetHeight(bounds) - (height + subtitleHeight))/2;
self.label.frame = CGRectMake(x,
- offset,
+ offset+statusBarOffset,
CGRectGetWidth(bounds)-x-kCRStatusBarViewNoImageRightContentInset,
height);
self.subtitleLabel.frame = CGRectMake(x,
- height+offset,
+ height+offset+statusBarOffset,
CGRectGetWidth(bounds)-x-kCRStatusBarViewNoImageRightContentInset,
subtitleHeight);
}
Something went wrong with that request. Please try again.