Skip to content

Commit

Permalink
增加文件
Browse files Browse the repository at this point in the history
  • Loading branch information
liaoyuanng committed Jun 16, 2017
1 parent 204ecbe commit a02c57e
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 0 deletions.
15 changes: 15 additions & 0 deletions LYSheetController/LYSheetMenu.h
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 */
89 changes: 89 additions & 0 deletions LYSheetController/LYSheetProtocol.h
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 */
14 changes: 14 additions & 0 deletions LYSheetController/UIViewController+LYActive.h
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
35 changes: 35 additions & 0 deletions LYSheetController/UIViewController+LYActive.m
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

0 comments on commit a02c57e

Please sign in to comment.