calimarkus / JDStatusBarNotification

Highly customizable & feature rich notifications. Interactive dismiss. Custom Views. SwiftUI. Tap-to-hold. Progress. Written in Swift, compatible for ObjC!
http://calimarkus.github.io/JDStatusBarNotification/documentation/jdstatusbarnotification
MIT License
4.22k stars 562 forks source link

Fit screen iPhoneX #89

Closed kb100824 closed 6 years ago

kb100824 commented 6 years ago

@calimarkus
I try to fit repair slove it:

1-->JDStatusBarView.m:

- (void)layoutSubviews;
{
  [super layoutSubviews];

#pragma mark - Fit screen iPhonex
    BOOL iPhoneX =  ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO);
  // label
    self.textLabel.frame = CGRectMake(0, 1+self.textVerticalPositionAdjustment+(iPhoneX?44:0),
                                    self.bounds.size.width, self.bounds.size.height-1);

  // activity indicator
  if (_activityIndicatorView ) {
    CGSize textSize = [self currentTextSize];
    CGRect indicatorFrame = _activityIndicatorView.frame;
    indicatorFrame.origin.x = round((self.bounds.size.width - textSize.width)/2.0) - indicatorFrame.size.width - 8.0;
    indicatorFrame.origin.y = ceil(1+(self.bounds.size.height - indicatorFrame.size.height)/2.0);
    _activityIndicatorView.frame = indicatorFrame;
  }
}
2-->JDStatusBarNotification.m

- (void)updateTopBarFrameWithStatusBarFrame:(CGRect)rect;
{
  CGFloat width = MAX(rect.size.width, rect.size.height);

#pragma mark - Fit screen iPhonex
    BOOL iPhoneX =  ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO);

    CGFloat height = MIN(rect.size.width, rect.size.height)+(iPhoneX?88:0);

  // on ios7 fix position, if statusBar has double height
  CGFloat yPos = 0;
  if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0 && height > 20.0) {
    yPos = -height/2.0;
  }

  _topBar.frame = CGRectMake(0, yPos, width, height);
}
calimarkus commented 6 years ago

Please describe the issue you are facing and if you submit code changes please send it as a pull request, so I could possible merge it.