forked from BigShow1949/BigShow1949
-
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
big show
committed
Oct 9, 2018
1 parent
f87e100
commit ac24158
Showing
96 changed files
with
6,508 additions
and
1,403 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
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
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
15 changes: 15 additions & 0 deletions
15
BigShow1949/Classes/03 - ViewLayout(视图布局)/YNPageView/Demos/BaseVC/BaseCollectionViewVC.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,15 @@ | ||
// | ||
// BaseCollectionViewVC.h | ||
// YNPageViewController | ||
// | ||
// Created by ZYN on 2018/6/22. | ||
// Copyright © 2018年 yongneng. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface BaseCollectionViewVC : UIViewController | ||
|
||
@property (nonatomic, strong) UICollectionView *collectionView; | ||
|
||
@end |
110 changes: 110 additions & 0 deletions
110
BigShow1949/Classes/03 - ViewLayout(视图布局)/YNPageView/Demos/BaseVC/BaseCollectionViewVC.m
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,110 @@ | ||
// | ||
// BaseCollectionViewVC.m | ||
// YNPageViewController | ||
// | ||
// Created by ZYN on 2018/6/22. | ||
// Copyright © 2018年 yongneng. All rights reserved. | ||
// | ||
|
||
#import "BaseCollectionViewVC.h" | ||
#import "MJRefresh.h" | ||
#define randomColor random(arc4random_uniform(256), arc4random_uniform(256), arc4random_uniform(256), arc4random_uniform(256)) | ||
#define random(r, g, b, a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:(a)/255.0] | ||
@interface BaseCollectionViewVC () <UICollectionViewDelegate, UICollectionViewDataSource> | ||
|
||
@end | ||
|
||
@implementation BaseCollectionViewVC | ||
|
||
- (void)viewDidLoad { | ||
[super viewDidLoad]; | ||
|
||
[self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"id"]; | ||
[self.collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:HeaderID]; | ||
[self.collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:FooterID]; | ||
[self.view addSubview:self.collectionView]; | ||
[self addCollectionViewRefresh]; | ||
} | ||
|
||
- (void)addCollectionViewRefresh { | ||
|
||
__weak typeof (self) weakSelf = self; | ||
|
||
self.collectionView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{ | ||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ | ||
[weakSelf.collectionView.mj_header endRefreshing]; | ||
}); | ||
}]; | ||
|
||
self.collectionView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{ | ||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ | ||
[weakSelf.collectionView.mj_footer endRefreshing]; | ||
}); | ||
}]; | ||
} | ||
|
||
#pragma mark - UICollectionViewDelegate, UICollectionViewDataSource | ||
|
||
static NSString *HeaderID = @"header"; | ||
|
||
static NSString *FooterID = @"footer"; | ||
|
||
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath { | ||
if (kind == UICollectionElementKindSectionHeader) { | ||
UICollectionReusableView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:HeaderID forIndexPath:indexPath]; | ||
headerView.backgroundColor = randomColor; | ||
return headerView; | ||
} else { // 返回每一组的尾部视图 | ||
UICollectionReusableView *footerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:FooterID forIndexPath:indexPath]; | ||
|
||
footerView.backgroundColor = randomColor; | ||
return footerView; | ||
} | ||
} | ||
|
||
/// collectinView section header 在高版本存在系统BUG,需要设置zPosition = 0.0 | ||
- (void)collectionView:(UICollectionView *)collectionView willDisplaySupplementaryView:(UICollectionReusableView *)view forElementKind:(NSString *)elementKind atIndexPath:(NSIndexPath *)indexPath { | ||
view.layer.zPosition = 0.0; | ||
} | ||
|
||
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section { | ||
return (CGSize){YFScreen.width * 0.5, 22}; | ||
} | ||
|
||
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section { | ||
return (CGSize){YFScreen.width, 22}; | ||
} | ||
|
||
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { | ||
return 3; | ||
} | ||
|
||
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { | ||
return 20; | ||
} | ||
|
||
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { | ||
|
||
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"id" forIndexPath:indexPath]; | ||
cell.backgroundColor = randomColor; | ||
return cell; | ||
} | ||
|
||
- (UICollectionView *)collectionView { | ||
if (!_collectionView) { | ||
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; | ||
layout.itemSize = CGSizeMake(100, 100); | ||
|
||
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) collectionViewLayout:layout]; | ||
_collectionView.dataSource = self; | ||
_collectionView.delegate = self; | ||
_collectionView.backgroundColor = [UIColor whiteColor]; | ||
} | ||
return _collectionView; | ||
} | ||
|
||
- (void)dealloc { | ||
NSLog(@"----- %@ delloc", self.class); | ||
} | ||
|
||
@end |
13 changes: 13 additions & 0 deletions
13
BigShow1949/Classes/03 - ViewLayout(视图布局)/YNPageView/Demos/BaseVC/BasePageViewController.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,13 @@ | ||
// | ||
// BasePageViewController.h | ||
// YNPageViewController | ||
// | ||
// Created by ZYN on 2018/7/27. | ||
// Copyright © 2018年 yongneng. All rights reserved. | ||
// 中间层 - 为了演示API功能操作 | ||
|
||
#import "YNPageViewController.h" | ||
|
||
@interface BasePageViewController : YNPageViewController | ||
|
||
@end |
122 changes: 122 additions & 0 deletions
122
BigShow1949/Classes/03 - ViewLayout(视图布局)/YNPageView/Demos/BaseVC/BasePageViewController.m
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,122 @@ | ||
// | ||
// BasePageViewController.m | ||
// YNPageViewController | ||
// | ||
// Created by ZYN on 2018/7/27. | ||
// Copyright © 2018年 yongneng. All rights reserved. | ||
// 中间层 - 为了演示API功能操作 | ||
|
||
#import "BasePageViewController.h" | ||
#import "BaseTableViewVC.h" | ||
#import "UIView+YNPageExtend.h" | ||
#import "FTPopOverMenu.h" | ||
@interface BasePageViewController () | ||
|
||
@end | ||
|
||
@implementation BasePageViewController | ||
|
||
#pragma mark - Life Cycle | ||
- (void)viewDidLoad { | ||
[super viewDidLoad]; | ||
|
||
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] | ||
initWithTitle:@"功能操作" | ||
style:UIBarButtonItemStylePlain | ||
target:self action:@selector(rightButtonOnClick:event:)]; | ||
} | ||
|
||
- (void)viewWillAppear:(BOOL)animated { | ||
[super viewWillAppear:animated]; | ||
NSLog(@"--%@--%@", [self class], NSStringFromSelector(_cmd)); | ||
} | ||
|
||
- (void)viewDidAppear:(BOOL)animated { | ||
[super viewDidAppear:animated]; | ||
NSLog(@"--%@--%@", [self class], NSStringFromSelector(_cmd)); | ||
} | ||
|
||
- (void)viewWillDisappear:(BOOL)animated { | ||
[super viewWillDisappear:animated]; | ||
NSLog(@"--%@--%@", [self class], NSStringFromSelector(_cmd)); | ||
} | ||
|
||
- (void)viewDidDisappear:(BOOL)animated { | ||
[super viewDidDisappear:animated]; | ||
NSLog(@"--%@--%@", [self class], NSStringFromSelector(_cmd)); | ||
} | ||
|
||
#pragma mark - Event Response | ||
|
||
#pragma mark - --Notification Event Response | ||
|
||
#pragma mark - --Button Event Response | ||
- (void)rightButtonOnClick:(UIBarButtonItem *)item event:(UIEvent *)event { | ||
__weak typeof(self) weakSelf = self; | ||
[FTPopOverMenu showFromEvent:event withMenuArray:@[@"滚动到顶部", | ||
@"更新菜单栏标题", | ||
@"添加页面", | ||
@"删除页面", | ||
@"调整标题顺序", | ||
@"reload", | ||
@"刷新头部高度"] doneBlock:^(NSInteger selectedIndex) { | ||
switch (selectedIndex) { | ||
case 0: | ||
{ | ||
[weakSelf scrollToTop:YES]; | ||
} | ||
break; | ||
case 1: | ||
{ | ||
// [self updateMenuItemTitle:@"更新的标题" index:0]; | ||
[weakSelf updateMenuItemTitles:@[@"足球", @"棒球", @"篮球"]]; | ||
} | ||
break; | ||
case 2: | ||
{ | ||
BaseTableViewVC *vc_1 = [[BaseTableViewVC alloc] init]; | ||
vc_1.cellTitle = @"插入页新面"; | ||
[weakSelf insertPageChildControllersWithTitles:@[@"插入页面"] controllers:@[vc_1] index:1]; | ||
} | ||
break; | ||
case 3: | ||
{ | ||
// [self removePageControllerWithTitle:@"帽子"]; | ||
[weakSelf removePageControllerWithIndex:0]; | ||
} | ||
break; | ||
case 4: | ||
{ | ||
[weakSelf replaceTitlesArrayForSort:@[@"帽子", @"衣服", @"鞋子"]]; | ||
} | ||
break; | ||
case 5: | ||
{ | ||
weakSelf.titlesM = @[@"刷新页面", @"棒球", @"篮球"].mutableCopy; | ||
weakSelf.config.menuHeight = 100; | ||
weakSelf.pageIndex = 0; | ||
[weakSelf reloadData]; | ||
} | ||
break; | ||
case 6: | ||
{ | ||
weakSelf.headerView.yn_height = 300; | ||
[weakSelf reloadData]; | ||
} | ||
break; | ||
} | ||
} dismissBlock:nil]; | ||
} | ||
#pragma mark - --Gesture Event Response | ||
|
||
#pragma mark - System Delegate | ||
|
||
#pragma mark - Custom Delegate | ||
|
||
#pragma mark - Public Function | ||
|
||
#pragma mark - Private Function | ||
|
||
#pragma mark - Getter and Setter | ||
|
||
@end |
19 changes: 19 additions & 0 deletions
19
BigShow1949/Classes/03 - ViewLayout(视图布局)/YNPageView/Demos/BaseVC/BaseTableViewVC.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,19 @@ | ||
// | ||
// BaseVC.h | ||
// YNPageViewController | ||
// | ||
// Created by ZYN on 2018/6/22. | ||
// Copyright © 2018年 yongneng. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface BaseTableViewVC : UIViewController | ||
|
||
@property (nonatomic, copy) NSString *cellTitle; | ||
|
||
@property (nonatomic, strong) UITableView *tableView; | ||
|
||
- (void)addTableViewRefresh; | ||
|
||
@end |
Oops, something went wrong.