Skip to content

Commit

Permalink
适配 iOS 13
Browse files Browse the repository at this point in the history
适配 iOS 13
  • Loading branch information
pikacode committed Oct 15, 2019
1 parent 2e28950 commit 4df7440
Show file tree
Hide file tree
Showing 78 changed files with 2,285 additions and 322 deletions.
Binary file modified .DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions EBBannerView.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Pod::Spec.new do |s|
#

s.name = "EBBannerView"
s.version = "1.1.0"
s.summary = "展示跟iOS9/10/11/12推送一样的横幅/提示音/振动,或自定义view|Show a banner the same with iOS9/10/11/12 nofitication(sound/vibrate), or customize."
s.version = "1.1.1"
s.summary = "展示跟iOS9~13推送一样的横幅/提示音/振动,或自定义view|Show a banner the same with iOS9/10/11/12 nofitication(sound/vibrate), or customize."

# This description is used to generate tags and improve search results.
# * Think: What does it do? Why did you write it? What is the focus?
Expand Down
2 changes: 1 addition & 1 deletion EBBannerView/Classes/EBBannerView+Categories.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ +(UInt32)defaultSoundID{
-(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event{
if (CGRectContainsPoint(self.frame, point)) {
return self;
}else{
} else {
return [super hitTest:point withEvent:event];
}
}
Expand Down
9 changes: 5 additions & 4 deletions EBBannerView/Classes/EBBannerView.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

NSString *const EBBannerViewDidClickNotification = @"EBBannerViewDidClickNotification";

@interface EBBannerView(){
@interface EBBannerView() {
NSTimer *_hideTimer;
}

Expand Down Expand Up @@ -87,7 +87,7 @@ -(void)show{
[[EBMuteDetector sharedDetecotr] detectComplete:^(BOOL isMute) {
if (isMute && weakSelf.maker.vibrateOnMute) {
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
}else{
} else {
AudioServicesPlaySystemSound(soundID);
}
}];
Expand Down Expand Up @@ -242,8 +242,9 @@ -(CGFloat)calculatedContentHeight{
}

-(BOOL)isiPhoneX{
if(@available(iOS 11.0, *)) {
return UIApplication.sharedApplication.delegate.window.safeAreaInsets.bottom > 0;
if (@available(iOS 11.0, *)) {
return UIApplication.sharedApplication.keyWindow.safeAreaInsets.bottom > 0;
// return UIApplication.sharedApplication.delegate.window.safeAreaInsets.bottom > 0;
} else {
return NO;
}
Expand Down
2 changes: 1 addition & 1 deletion EBBannerView/Classes/EBBannerViewMaker.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ @implementation EBBannerViewMaker
+(instancetype)defaultMaker{
EBBannerViewMaker *maker = [EBBannerViewMaker new];
maker.style = MAX(UIDevice.currentDevice.systemVersion.intValue, 9);
maker.icon = [UIImage imageNamed:@"AppIcon40x40"] ?: [UIImage imageNamed:@"AppIcon60x60"] ?: [UIImage imageNamed:@"AppIcon80x80"];
maker.icon = [UIImage imageNamed:@"AppIcon40x40"] ?: [UIImage imageNamed:@"AppIcon60x60"] ?: [UIImage imageNamed:@"AppIcon80x80"] ?: [UIImage imageNamed:@"AppIcon"];
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
maker.title = [infoDictionary objectForKey:@"CFBundleDisplayName"] ?: [infoDictionary objectForKey:@"CFBundleName"];
maker.date = NSLocalizedString(@"现在", nil);
Expand Down
21 changes: 17 additions & 4 deletions EBBannerView/Classes/EBBannerWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ @implementation EBBannerWindow
+(instancetype)sharedWindow{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedWindow = [[self alloc] initWithFrame:CGRectZero];
if (@available(iOS 13.0, *)) {
sharedWindow = [[EBBannerWindow alloc] initWithWindowScene:UIApplication.sharedApplication.keyWindow.windowScene];
} else {
// Fallback on earlier versions
sharedWindow = [[self alloc] initWithFrame:CGRectZero];
}
sharedWindow.windowLevel = UIWindowLevelAlert;
sharedWindow.layer.masksToBounds = NO;
UIWindow *originKeyWindow = UIApplication.sharedApplication.keyWindow;
Expand Down Expand Up @@ -64,8 +69,12 @@ -(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event{
if (view) {
CGPoint point1 = [self convertPoint:point toView:view];
return [view hitTest:point1 withEvent:event];
}else{
return [super hitTest:point withEvent:event];
} else {
if (@available(iOS 13.0, *)) {
return [UIApplication.sharedApplication.keyWindow hitTest:point withEvent:event];
} else {
return [super hitTest:point withEvent:event];
}
}
}

Expand All @@ -76,7 +85,11 @@ -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NS
}

-(void)dealloc{
[self removeObserver:self forKeyPath:@"frame"];
if (@available(iOS 13.0, *)) {

} else {
[self removeObserver:self forKeyPath:@"frame"];
}
}

@end
6 changes: 3 additions & 3 deletions EBBannerView/Classes/EBCustomBannerView.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ -(void)applicationDidChangeStatusBarOrientationNotification{
[sharedCustomViews enumerateObjectsUsingBlock:^(EBCustomBannerView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
obj.maker.view.frame = obj.maker.landscapeFrame;
}];
}else{
} else {
[sharedCustomViews enumerateObjectsUsingBlock:^(EBCustomBannerView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
obj.maker.view.frame = obj.maker.portraitFrame;
}];
Expand All @@ -95,14 +95,14 @@ -(void)show{
if (_maker.soundName) {
NSURL *url = [[NSBundle mainBundle] URLForResource:_maker.soundName withExtension:nil];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)(url), &soundID);
}else{
} else {
soundID = _maker.soundID;
}
WEAK_SELF(weakSelf);
[[EBMuteDetector sharedDetecotr] detectComplete:^(BOOL isMute) {
if (isMute && weakSelf.maker.vibrateOnMute) {
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
}else{
} else {
AudioServicesPlaySystemSound(soundID);
}
}];
Expand Down
4 changes: 2 additions & 2 deletions EBBannerView/Classes/EBMuteDetector.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ +(EBMuteDetector*)sharedDetecotr{
dispatch_once(&onceToken, ^{
sharedDetecotr = [EBMuteDetector new];
NSURL* url = [[NSBundle bundleForClass:[self class]] URLForResource:@"EBMuteDetector" withExtension:@"mp3"];
if (AudioServicesCreateSystemSoundID((__bridge CFURLRef)url, &sharedDetecotr->_soundId) == kAudioServicesNoError){
if (AudioServicesCreateSystemSoundID((__bridge CFURLRef)url, &sharedDetecotr->_soundId) == kAudioServicesNoError) {
AudioServicesAddSystemSoundCompletion(sharedDetecotr.soundId, CFRunLoopGetMain(), kCFRunLoopDefaultMode, EBSoundMuteNotificationCompletionProc,(__bridge void *)(self));
UInt32 yes = 1;
AudioServicesSetProperty(kAudioServicesPropertyIsUISound, sizeof(sharedDetecotr.soundId),&sharedDetecotr->_soundId,sizeof(yes), &yes);
Expand All @@ -54,7 +54,7 @@ -(void)detectComplete:(void (^)(BOOL isMute))completionHandler{
}

-(void)dealloc{
if (self.soundId != -1){
if (self.soundId != -1) {
AudioServicesRemoveSystemSoundCompletion(self.soundId);
AudioServicesDisposeSystemSoundID(self.soundId);
}
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Email:pikacode@qq.com

Only one line to show:

- a banner the same style as iOS Push Notifications (auto show iOS 9/10/11/12 styles up to system version)
- a banner the same style as iOS Push Notifications (auto show iOS 9~13 styles up to system version)
- auto play a sound or vibrate when the banner is showing


Expand Down Expand Up @@ -72,7 +72,7 @@ And more:

#### 1.Show a iOS style banner with one line

up to system version,will show iOS 9/10/11 style,auto show app icon/name.
up to system version,will show iOS 9~13 style,auto show app icon/name.

```objc
[EBBannerView showWithContent:@"custom content"];
Expand Down
4 changes: 2 additions & 2 deletions README_CHS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Email:pikacode@qq.com

只需一行代码即可:

- App 在前台时展示跟 iOS9/10/11/12 推送通知一样 UI 的横幅,自动根据系统版本显示不同 UI
- App 在前台时展示跟 iOS 9~13 推送通知一样 UI 的横幅,自动根据系统版本显示不同 UI


- 根据手机是否静音自动播放提示音或振动
Expand Down Expand Up @@ -70,7 +70,7 @@ Email:pikacode@qq.com

#### 方式一:一行代码搞定之省心模式

根据系统不同自动展示 iOS 9/10/11 的样式,并自动展示 app 名称 图标等。
根据系统不同自动展示 iOS 9~13 的样式,并自动展示 app 名称 图标等。

```objc
[EBBannerView showWithContent:@"自定义内容"];
Expand Down
4 changes: 4 additions & 0 deletions demo ios 13/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
target 'demo13' do
# pod 'EBBannerView', '1.1.1'
pod 'EBBannerView', :path => '../../EBBannerView'
end
16 changes: 16 additions & 0 deletions demo ios 13/Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
PODS:
- EBBannerView (1.1.0)

DEPENDENCIES:
- EBBannerView (from `../../EBBannerView`)

EXTERNAL SOURCES:
EBBannerView:
:path: "../../EBBannerView"

SPEC CHECKSUMS:
EBBannerView: 3d987535d0236c1f87c2b064267d94002c23dd1e

PODFILE CHECKSUM: 23968f70e412e70c79ac1399f880caf17dfc39d2

COCOAPODS: 1.7.5

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions demo ios 13/Pods/Local Podspecs/EBBannerView.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions demo ios 13/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4df7440

Please sign in to comment.