Skip to content

Commit

Permalink
Merge pull request #13 from cntrump/master
Browse files Browse the repository at this point in the history
支持 iOS 13,和支持 Carthage 集成
  • Loading branch information
GIKICoder committed Nov 8, 2019
2 parents 16a12c6 + 0d70c9f commit 918b251
Show file tree
Hide file tree
Showing 11 changed files with 566 additions and 81 deletions.
389 changes: 389 additions & 0 deletions GMenuController.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1120"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "153D515C2373F497009B9653"
BuildableName = "GMenuController.framework"
BlueprintName = "GMenuController"
ReferencedContainer = "container:GMenuController.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "153D515C2373F497009B9653"
BuildableName = "GMenuController.framework"
BlueprintName = "GMenuController"
ReferencedContainer = "container:GMenuController.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
19 changes: 5 additions & 14 deletions GMenuController/GMenuController.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@

NS_ASSUME_NONNULL_BEGIN


@class GMenuItem,GMenuViewContainer;
@class GMenuItem, GMenuViewContainer;

@interface GMenuController : NSObject

Expand All @@ -26,29 +25,21 @@ NS_ASSUME_NONNULL_BEGIN

@property(nullable, nonatomic,copy) NSArray<GMenuItem *> *menuItems; // default is nil. these are in addition to the standard items

@property (nonatomic, readonly) GMenuViewContainer * menuViewContainer;

- (void)setMenuVisible:(BOOL)menuVisible animated:(BOOL)animated;

- (void)setTargetRect:(CGRect)targetRect inView:(UIView *)targetView;

- (void)update;

- (void)reset; /// reset menuViewContrainer configs

@property(nonatomic,readonly) CGRect menuFrame;

@property(nonatomic,readonly) GMenuViewContainer * menuViewContainer;

@end

NS_ASSUME_NONNULL_END

NS_ASSUME_NONNULL_BEGIN
@interface GMenuItem : NSObject

- (instancetype)initWithTitle:(NSString *)title target:(id)target action:(SEL)action;
- (instancetype)initWithTitle:(NSString *)title image:(UIImage*)image target:(id)target action:(SEL)action;
@property(nonatomic,copy) NSString *title;
@property (nonatomic, strong) UIImage * image;
@property (nonatomic, strong) id target;
@property(nonatomic) SEL action;

@end
NS_ASSUME_NONNULL_END
17 changes: 3 additions & 14 deletions GMenuController/GMenuController.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,14 @@
#import "GMenuController.h"
#import "GMenuEffectsWindow.h"
#import "GMenuViewContainer.h"
#import "GMenuController_internal.h"

NSNotificationName const GMenuControllerWillShowMenuNotification = @"GMenuControllerWillShowMenuNotification_private";
NSNotificationName const GMenuControllerDidShowMenuNotification= @"GMenuControllerDidShowMenuNotification_private";
NSNotificationName const GMenuControllerWillHideMenuNotification= @"GMenuControllerWillHideMenuNotification_private";
NSNotificationName const GMenuControllerDidHideMenuNotification= @"GMenuControllerDidHideMenuNotification_private";
NSNotificationName const GMenuControllerMenuFrameDidChangeNotification= @"GMenuControllerMenuFrameDidChangeNotification_private";

@interface GMenuController()

@property (nonatomic, strong,readwrite) GMenuViewContainer * menuViewContainer;
@property (nonatomic, weak) UIView * targetView;
@end

@implementation GMenuController

#pragma mark - init
Expand All @@ -29,7 +25,7 @@ - (instancetype)init
{
self = [super init];
if (self) {

_menuViewContainer = [GMenuViewContainer new];
}
return self;
}
Expand Down Expand Up @@ -107,13 +103,6 @@ - (void)setArrowDirection:(GMenuControllerArrowDirection)arrowDirection
self.menuViewContainer.arrowDirection = arrowDirection;
}

- (GMenuViewContainer *)menuViewContainer
{
if (!_menuViewContainer) {
_menuViewContainer = [GMenuViewContainer new];
}
return _menuViewContainer;
}
@end

@implementation GMenuItem
Expand Down
32 changes: 32 additions & 0 deletions GMenuController/Internal/GMenuController_internal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// GMenuController_internal.h
// GMenuController
//
// Created by v on 2019/11/7.
// Copyright © 2019 GIKI. All rights reserved.
//

#ifndef GMenuController_internal_h
#define GMenuController_internal_h

@interface GMenuController ()

@property (nonatomic, weak) UIView * targetView;
@property (nonatomic, readonly) CGRect menuFrame;

- (void)update;

- (void)reset; /// reset menuViewContrainer configs

@end

@interface GMenuItem ()

@property (nonatomic, copy) NSString *title;
@property (nonatomic, strong) UIImage * image;
@property (nonatomic, strong) id target;
@property (nonatomic) SEL action;

@end

#endif /* GMenuController_internal_h */
2 changes: 2 additions & 0 deletions GMenuController/Internal/GMenuDefaultView.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#import "GMenuController.h"
#import "GMenuViewContainer.h"
#import "GAdjustButton.h"
#import "GMenuController_internal.h"

@interface GMenuItemDefaultView:GAdjustButton
@property (nonatomic, strong) UIColor *highlightedColor;
@property (nonatomic, strong) UIImageView *effectView;
Expand Down
16 changes: 14 additions & 2 deletions GMenuController/Internal/GMenuEffectsWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,25 @@ + (instancetype)sharedWindow

- (void)showMenu:(GMenuViewContainer *)menu animation:(BOOL)animation
{
if(!menu) return;
if (!menu) return;

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
if (@available(iOS 13.0, *)) {
for (UIWindowScene *scene in [UIApplication sharedApplication].connectedScenes) {
if (scene.activationState == UISceneActivationStateForegroundActive) {
self.windowScene = scene;
break;
}
}
}
#endif

menu.alpha = 0;
if(menu.superview != self) [self addSubview:menu];
self.menuVisible = YES;
self.currentMenu = menu;
[self updateWindowLevel];

if (animation) {
NSTimeInterval time = 0.16;
[UIView animateWithDuration:time delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
Expand Down
Loading

0 comments on commit 918b251

Please sign in to comment.