-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
204ecbe
commit a02c57e
Showing
4 changed files
with
153 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// LYSheetMenu.h | ||
// LYSheetControllerDemo | ||
// | ||
// Created by Ju Liaoyuan on 2017/5/23. | ||
// Copyright © 2017年 Leo. All rights reserved. | ||
// | ||
|
||
#ifndef LYSheetMenu_h | ||
#define LYSheetMenu_h | ||
|
||
#import "LYSheetProtocol.h" | ||
#import "LYSheetController.h" | ||
|
||
#endif /* LYSheetMenu_h */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// | ||
// LYSheetProtocal.h | ||
// LYSheetControllerDemo | ||
// | ||
// Created by Ju Liaoyuan on 2017/5/22. | ||
// Copyright © 2017年 Leo. All rights reserved. | ||
// | ||
|
||
#ifndef LYSheetProtocal_h | ||
#define LYSheetProtocal_h | ||
|
||
@class LYSheetProtocol; | ||
@class LYSheetController; | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
typedef NS_OPTIONS(NSInteger, LYSheetStyle) { | ||
LYSheetStyleDefault = 1 << 0, | ||
LYSheetStyleCancel = 1 << 1 | ||
}; | ||
|
||
#pragma mark - LYSheetControllerDelegate | ||
#pragma mark | ||
|
||
@protocol LYSheetControllerDelegate <NSObject> | ||
|
||
@optional | ||
|
||
- (void)sheetController:(LYSheetController *)sheetController didSelectRowAtIndexPath:(NSInteger)indexPath; | ||
|
||
- (CGFloat)headerHeightForSheetContoller:(LYSheetController *)sheetController; | ||
|
||
- (UIView *)headerViewForSheetContoller:(LYSheetController *)sheetController; | ||
|
||
@end | ||
|
||
#pragma mark - LYSheetModel | ||
#pragma mark | ||
|
||
@protocol LYSheetModel <NSObject> | ||
|
||
@required | ||
|
||
/** | ||
sheet style, required. | ||
*/ | ||
@property (nonatomic, assign) LYSheetStyle sheetStyle; | ||
|
||
@optional | ||
|
||
/** | ||
sheet action | ||
*/ | ||
@property (nonatomic, assign, nullable) SEL sheetAction; | ||
|
||
/** | ||
sheet title | ||
*/ | ||
@property (nonatomic, copy, nullable) NSString *sheetTitle; | ||
|
||
/** | ||
sheet image; | ||
*/ | ||
@property (nonatomic, strong, nullable) UIImage *sheetImage; | ||
|
||
- (instancetype)initWithSheetTitle:(NSString *)aTitle selector:(nullable SEL)aSel; | ||
|
||
- (instancetype)initWithSheetTitle:(NSString *)aTitle selector:(nullable SEL)aSel style:(LYSheetStyle)aStyle; | ||
|
||
@end | ||
|
||
#pragma mark - LYSheetCell | ||
#pragma mark | ||
|
||
@protocol LYSheetCell <NSObject> | ||
|
||
@optional | ||
|
||
@property (nonatomic, strong) UILabel *titleLabel; | ||
|
||
@property (nonatomic, strong) UIImageView *imageView; | ||
|
||
- (void)bindModel:(id<LYSheetModel>)model; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END | ||
|
||
#endif /* LYSheetProtocal_h */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// UIViewController+Active.h | ||
// | ||
// Created by JuLiaoyuan on 16/8/18. | ||
// Copyright © 2016年 Spark. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface UIViewController (LYActive) | ||
|
||
+ (UIViewController *)activeViewController; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// UIViewController+Active.m | ||
// | ||
// Created by JuLiaoyuan on 16/8/18. | ||
// Copyright © 2016年 Spark. All rights reserved. | ||
// | ||
|
||
#import "UIViewController+LYActive.h" | ||
|
||
@implementation UIViewController (LYActive) | ||
|
||
+ (UIViewController *)activeViewController { | ||
UIViewController *viewController = [[UIViewController alloc] init]; | ||
id rootVC = [UIApplication sharedApplication].keyWindow.rootViewController; | ||
return [viewController activeViewController:rootVC]; | ||
} | ||
- (UIViewController *)activeViewController:(id)viewController { | ||
if ([viewController isKindOfClass:[UITabBarController class]]) { | ||
UITabBarController *tab = (UITabBarController *)viewController; | ||
return [self activeViewController:tab.selectedViewController]; | ||
} | ||
if ([viewController isKindOfClass:[UINavigationController class]]) { | ||
UINavigationController *nav = (UINavigationController *)viewController; | ||
return [nav visibleViewController]; | ||
} | ||
if ([viewController isKindOfClass:[UIViewController class]]) { | ||
UIViewController *active = viewController; | ||
while (active.presentedViewController) { | ||
active = active.presentedViewController; | ||
} | ||
return active; | ||
} | ||
return nil; | ||
} | ||
@end |