├── .gitignore ├── JHPageController ├── JHPageController.h └── JHPageController.m ├── JHPageMenuView ├── JHPageDecorateBuiltInItem.h ├── JHPageDecorateBuiltInItem.m ├── JHPageDecorateView.h ├── JHPageDecorateView.m ├── JHPageMenuConstant.h ├── JHPageMenuItem.h ├── JHPageMenuItem.m ├── JHPageMenuView.h └── JHPageMenuView.m ├── JHPageMenuViewDemo ├── JHPageMenuViewDemo.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── JHPageMenuViewDemo.xcworkspace │ └── contents.xcworkspacedata ├── JHPageMenuViewDemo │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── Contents.json │ │ ├── triangle_left.imageset │ │ │ ├── Contents.json │ │ │ └── triangle_left.png │ │ └── triangle_top.imageset │ │ │ ├── Contents.json │ │ │ └── Triangle.png │ ├── Base.lproj │ │ └── LaunchScreen.storyboard │ ├── Info.plist │ ├── View │ │ ├── CustomDecorateItem.h │ │ ├── CustomDecorateItem.m │ │ ├── CustomDecorateItem.xib │ │ ├── CustomMenuItem.h │ │ ├── CustomMenuItem.m │ │ └── CustomMenuItem.xib │ ├── ViewController │ │ ├── MenuDirectionViewController.h │ │ ├── MenuDirectionViewController.m │ │ ├── MenuStylesViewController.h │ │ ├── MenuStylesViewController.m │ │ ├── MenuViewController.h │ │ ├── MenuViewController.m │ │ ├── NavTabMenuViewController.h │ │ ├── NavTabMenuViewController.m │ │ ├── PageControllerStyleViewController.h │ │ ├── PageControllerStyleViewController.m │ │ ├── PageControllerViewController.h │ │ └── PageControllerViewController.m │ └── main.m ├── JHPageMenuViewDemoTests │ ├── Info.plist │ └── JHPageMenuViewDemoTests.m ├── JHPageMenuViewDemoUITests │ ├── Info.plist │ └── JHPageMenuViewDemoUITests.m ├── Podfile ├── Podfile.lock └── Pods │ ├── Headers │ ├── Private │ │ └── Masonry │ │ │ ├── MASCompositeConstraint.h │ │ │ ├── MASConstraint+Private.h │ │ │ ├── MASConstraint.h │ │ │ ├── MASConstraintMaker.h │ │ │ ├── MASLayoutConstraint.h │ │ │ ├── MASUtilities.h │ │ │ ├── MASViewAttribute.h │ │ │ ├── MASViewConstraint.h │ │ │ ├── Masonry.h │ │ │ ├── NSArray+MASAdditions.h │ │ │ ├── NSArray+MASShorthandAdditions.h │ │ │ ├── NSLayoutConstraint+MASDebugAdditions.h │ │ │ ├── View+MASAdditions.h │ │ │ ├── View+MASShorthandAdditions.h │ │ │ └── ViewController+MASAdditions.h │ └── Public │ │ └── Masonry │ │ ├── MASCompositeConstraint.h │ │ ├── MASConstraint+Private.h │ │ ├── MASConstraint.h │ │ ├── MASConstraintMaker.h │ │ ├── MASLayoutConstraint.h │ │ ├── MASUtilities.h │ │ ├── MASViewAttribute.h │ │ ├── MASViewConstraint.h │ │ ├── Masonry.h │ │ ├── NSArray+MASAdditions.h │ │ ├── NSArray+MASShorthandAdditions.h │ │ ├── NSLayoutConstraint+MASDebugAdditions.h │ │ ├── View+MASAdditions.h │ │ ├── View+MASShorthandAdditions.h │ │ └── ViewController+MASAdditions.h │ ├── Manifest.lock │ ├── Masonry │ ├── LICENSE │ ├── Masonry │ │ ├── MASCompositeConstraint.h │ │ ├── MASCompositeConstraint.m │ │ ├── MASConstraint+Private.h │ │ ├── MASConstraint.h │ │ ├── MASConstraint.m │ │ ├── MASConstraintMaker.h │ │ ├── MASConstraintMaker.m │ │ ├── MASLayoutConstraint.h │ │ ├── MASLayoutConstraint.m │ │ ├── MASUtilities.h │ │ ├── MASViewAttribute.h │ │ ├── MASViewAttribute.m │ │ ├── MASViewConstraint.h │ │ ├── MASViewConstraint.m │ │ ├── Masonry.h │ │ ├── NSArray+MASAdditions.h │ │ ├── NSArray+MASAdditions.m │ │ ├── NSArray+MASShorthandAdditions.h │ │ ├── NSLayoutConstraint+MASDebugAdditions.h │ │ ├── NSLayoutConstraint+MASDebugAdditions.m │ │ ├── View+MASAdditions.h │ │ ├── View+MASAdditions.m │ │ ├── View+MASShorthandAdditions.h │ │ ├── ViewController+MASAdditions.h │ │ └── ViewController+MASAdditions.m │ └── README.md │ ├── Pods.xcodeproj │ └── project.pbxproj │ └── Target Support Files │ ├── Masonry │ ├── Masonry-dummy.m │ ├── Masonry-prefix.pch │ └── Masonry.xcconfig │ └── Pods-JHPageMenuViewDemo │ ├── Pods-JHPageMenuViewDemo-acknowledgements.markdown │ ├── Pods-JHPageMenuViewDemo-acknowledgements.plist │ ├── Pods-JHPageMenuViewDemo-dummy.m │ ├── Pods-JHPageMenuViewDemo-frameworks.sh │ ├── Pods-JHPageMenuViewDemo-resources.sh │ ├── Pods-JHPageMenuViewDemo.debug.xcconfig │ └── Pods-JHPageMenuViewDemo.release.xcconfig ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | # CocoaPods 32 | # 33 | # We recommend against adding the Pods directory to your .gitignore. However 34 | # you should judge for yourself, the pros and cons are mentioned at: 35 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 36 | # 37 | # Pods/ 38 | 39 | # Carthage 40 | # 41 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 42 | # Carthage/Checkouts 43 | 44 | Carthage/Build 45 | 46 | # fastlane 47 | # 48 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 49 | # screenshots whenever they are needed. 50 | # For more information about the recommended setup visit: 51 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 52 | 53 | fastlane/report.xml 54 | fastlane/Preview.html 55 | fastlane/screenshots 56 | fastlane/test_output 57 | 58 | # Code Injection 59 | # 60 | # After new code Injection tools there's a generated folder /iOSInjectionProject 61 | # https://github.com/johnno1962/injectionforxcode 62 | 63 | iOSInjectionProject/ 64 | -------------------------------------------------------------------------------- /JHPageController/JHPageController.h: -------------------------------------------------------------------------------- 1 | // 2 | // JHPageController.h 3 | // JHPageMenuViewDemo 4 | // 5 | // Created by 谭高丰 on 2017/9/26. 6 | // Copyright © 2017年 谭高丰. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "JHPageMenuView.h" 11 | @class JHPageController; 12 | 13 | /** 14 | 菜单的位置类型 15 | */ 16 | typedef NS_ENUM(NSInteger, JHPageMenuLocationStyle) { 17 | JHPageMenuLocationStyleTop, // 菜单在顶部 18 | JHPageMenuLocationStyleLeft, // 菜单在左边 19 | JHPageMenuLocationStyleBottom, // 菜单在底部 20 | JHPageMenuLocationStyleRight, // 菜单在右边 21 | JHPageMenuLocationStyleNavBar, // 菜单在导航条上 22 | }; 23 | 24 | @protocol JHPageControllerDataSource 25 | @required 26 | 27 | /** 28 | 告知 "JHPageController" 需要多少个子控制器 29 | 30 | @param pageController JHPageController 31 | @return 子控制器个数 32 | */ 33 | - (NSInteger)numbersOfViewControllerInPageController:(JHPageController *)pageController; 34 | 35 | /** 36 | 通过对应的子控制器获取其在数据源中的下标 37 | 38 | @param viewController 子控制器 39 | @return 当前自控制器在数据源中的位置 40 | */ 41 | - (NSInteger)indexOfViewController:(UIViewController *)viewController; 42 | 43 | /** 44 | 告知 "JHPageController" 需要显示的每个子控制器 45 | 46 | @param pageController JHPageController 47 | @param index 下标 48 | @return 子控制器 49 | */ 50 | - (UIViewController *)pageController:(JHPageController *)pageController viewContrlllerAtIndex:(NSInteger)index; 51 | 52 | /** 53 | 告知 "JHPageController" 需要显示的每个菜单的Item 54 | 55 | @param pageController JHPageController 56 | @param menuView JHPageMenuView 57 | @param index 下标 58 | @return 菜单Item 59 | */ 60 | - (JHPageMenuItem *)pageController:(JHPageController *)pageController menuView:(JHPageMenuView *)menuView menuItemAtIndex:(NSInteger)index; 61 | 62 | @optional 63 | 64 | /** 65 | 告知 "JHPageController" 的 "JHMenuView" 需要显示的装饰器视图,如果实现了这个方法,且返回的装饰器视图不为nil,装饰器视图就会使用自定义的,设置的内置装饰器样式将不会生效 66 | 67 | @param pageController JHPageController 68 | @param menuView JHPageMenuView 69 | @return 装饰器 70 | */ 71 | - (UIView *)decorateItemInPageController:(JHPageController *)pageController menuView:(JHPageMenuView *)menuView; 72 | 73 | @end 74 | 75 | @protocol JHPageControllerDelegate 76 | 77 | /** 78 | 当子控制器将要进入用户的视线时调用,在这个时候如果想要做一些准备事情,可以在这个里面设置 79 | 80 | @param pageController JHPageController 81 | @param index 将要出现的子控制器的下标 82 | */ 83 | - (void)pageController:(JHPageController *)pageController willEnterViewControllerAtIndex:(NSInteger)index; 84 | 85 | /** 86 | 当子控制器已经进入用户的视线时调用,在这个时候如果想要做一些事情,可以在这个里面设置 87 | 88 | @param pageController JHPageController 89 | @param index 已经出现的子控制器的下标 90 | */ 91 | - (void)pageController:(JHPageController *)pageController didEnterViewControllerAtIndex:(NSInteger)index; 92 | 93 | @end 94 | 95 | @interface JHPageController : UIViewController 96 | 97 | /** 代理 */ 98 | @property (nonatomic, weak) id dataSource; 99 | @property (nonatomic, weak) id delegate; 100 | 101 | /** 设置当前选中的下标 */ 102 | @property (nonatomic, assign) NSInteger selectIndex; 103 | 104 | /** 菜单Item大小,默认为CGRectZero,所以一定要设置 */ 105 | @property (nonatomic, assign) CGSize menuItemSize; 106 | /** 内置的装饰器大小,不设置的话默认和菜单大小一致 */ 107 | @property (nonatomic, assign) CGSize decorateSize; 108 | /** 内置的装饰器样式,默认为JHPageDecorateStyleDefault,当设置了自定义的装饰器时,设置的该属性不会生效 */ 109 | @property (nonatomic, assign) JHPageDecorateStyle decorateStyle; 110 | /** 内置的装饰器样式的颜色,默认为红色 */ 111 | @property (nonatomic, strong) UIColor *decorateColor; 112 | 113 | /********************** 菜单视图本身的相关样式设置 ************************/ 114 | /** 菜单背景颜色,默认为 groupTableViewBackgroundColor */ 115 | @property (nonatomic, strong) UIColor *menuBackgroundColor; 116 | /** 菜单的大小(只有菜单设置了在导航栏上才会生效) */ 117 | @property (nonatomic, assign) CGSize menuSize; 118 | /** 菜单边框的大小,默认没有边框 */ 119 | @property (nonatomic, assign) CGFloat menuBorderWidth; 120 | /** 菜单边框的颜色,默认没有边框 */ 121 | @property (nonatomic, strong) UIColor *menuBorderColor; 122 | /** 菜单的圆弧半径,默认为0 */ 123 | @property (nonatomic, assign) CGFloat menuCornerRadius; 124 | 125 | /** 126 | 初始化方法,推荐使用,初始化的时候就设置菜单位置类型 127 | 128 | @param menulocationStyle 菜单的位置类型,支持上下左右,默认是顶部 129 | @param navBarController 如果菜单的位置类型为导航栏上,那么必须设置该属性为对应navbar的控制器,不然没有效果;其他情况下可以设置nil 130 | @return JHPageController实例 131 | */ 132 | - (instancetype)initWithMenuLocationStyle:(JHPageMenuLocationStyle)menulocationStyle navBarController:(UIViewController *)navBarController; 133 | 134 | /** 135 | 该方法用于重置刷新父控制器,该刷新包括顶部 MenuView 和 childViewControllers. 136 | */ 137 | - (void)reloadData; 138 | 139 | @end 140 | -------------------------------------------------------------------------------- /JHPageMenuView/JHPageDecorateBuiltInItem.h: -------------------------------------------------------------------------------- 1 | // 2 | // JHPageDecorateBuiltInItem.h 3 | // JHPageMenuViewDemo 4 | // 5 | // Created by 谭高丰 on 2017/9/23. 6 | // Copyright © 2017年 谭高丰. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "JHPageMenuConstant.h" 11 | 12 | @interface JHPageDecorateBuiltInItem : UIView 13 | 14 | @property (nonatomic, assign) JHPageMenuScrollDirection scrollDirection; 15 | @property (nonatomic, assign) JHPageDecorateStyle decorateStyle; 16 | @property (nonatomic, strong) UIColor *decorateColor; 17 | @property (nonatomic, assign) CGSize decorateSize; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /JHPageMenuView/JHPageDecorateBuiltInItem.m: -------------------------------------------------------------------------------- 1 | // 2 | // JHPageDecorateBuiltInItem.m 3 | // JHPageMenuViewDemo 4 | // 5 | // Created by 谭高丰 on 2017/9/23. 6 | // Copyright © 2017年 谭高丰. All rights reserved. 7 | // 8 | 9 | #import "JHPageDecorateBuiltInItem.h" 10 | 11 | @interface JHPageDecorateBuiltInItem () 12 | @property (nonatomic, weak) UIView *contentView; 13 | @end 14 | 15 | @implementation JHPageDecorateBuiltInItem 16 | 17 | #pragma mark - init 18 | 19 | - (void)awakeFromNib { 20 | [super awakeFromNib]; 21 | } 22 | 23 | - (instancetype)init { 24 | self = [super init]; 25 | if (self) { 26 | } 27 | return self; 28 | } 29 | 30 | #pragma mark - setter 31 | 32 | - (void)setDecorateStyle:(JHPageDecorateStyle)decorateStyle { 33 | [self.contentView removeFromSuperview]; 34 | switch (decorateStyle) { 35 | case JHPageDecorateStyleDefault: 36 | break; 37 | case JHPageDecorateStyleLine: 38 | [self addLineView]; 39 | break; 40 | case JHPageDecorateStyleFlood: 41 | [self addFloodView]; 42 | break; 43 | case JHPageDecorateStyleFloodHollow: 44 | [self addFloodHollowView]; 45 | break; 46 | } 47 | } 48 | 49 | #pragma mark - private 50 | 51 | - (void)addLineView { 52 | UIView *lineView = [[UIView alloc] init]; 53 | lineView.backgroundColor = self.decorateColor; 54 | self.contentView = lineView; 55 | [self addSubview:self.contentView]; 56 | [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) { 57 | if (self.scrollDirection == JHPageMenuScrollDirectionHorizontal) { 58 | make.centerX.equalTo(self); 59 | make.bottom.equalTo(self); 60 | } else { 61 | make.centerY.equalTo(self); 62 | make.right.equalTo(self); 63 | } 64 | make.height.mas_equalTo(self.decorateSize.height); 65 | make.width.mas_equalTo(self.decorateSize.width); 66 | }]; 67 | } 68 | 69 | - (void)addFloodView { 70 | UIView *floodView = [[UIView alloc] init]; 71 | floodView.layer.cornerRadius = self.decorateSize.height/2; 72 | floodView.backgroundColor = self.decorateColor; 73 | self.contentView = floodView; 74 | [self addSubview:self.contentView]; 75 | [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) { 76 | make.center.equalTo(self); 77 | make.width.mas_equalTo(self.decorateSize.width); 78 | make.height.mas_equalTo(self.decorateSize.height); 79 | }]; 80 | } 81 | 82 | - (void)addFloodHollowView { 83 | UIView *floodHollowView = [[UIView alloc] init]; 84 | floodHollowView.backgroundColor = [UIColor clearColor]; 85 | floodHollowView.layer.borderWidth = 1; 86 | floodHollowView.layer.borderColor = self.decorateColor.CGColor; 87 | floodHollowView.layer.cornerRadius = self.decorateSize.height/2; 88 | self.contentView = floodHollowView; 89 | [self addSubview:self.contentView]; 90 | [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) { 91 | make.center.equalTo(self); 92 | make.width.mas_equalTo(self.decorateSize.width); 93 | make.height.mas_equalTo(self.decorateSize.height); 94 | }]; 95 | } 96 | 97 | @end 98 | -------------------------------------------------------------------------------- /JHPageMenuView/JHPageDecorateView.h: -------------------------------------------------------------------------------- 1 | // 2 | // JHPageDecorateView.h 3 | // JHPageMenuViewDemo 4 | // 5 | // Created by 谭高丰 on 2017/9/23. 6 | // Copyright © 2017年 谭高丰. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "JHPageMenuConstant.h" 11 | 12 | @interface JHPageDecorateView : UIView 13 | 14 | /** 滚动视图 */ 15 | @property (nonatomic, strong) UIScrollView *scrollView; 16 | 17 | /** 18 | 设置属性 19 | 20 | @param decorateItem 装饰器 21 | @param scrollDirection 滚动方向 22 | @param decorateNumbers 装饰器个数 23 | @param decorateSize 装饰器大小 24 | */ 25 | - (void)setDecorateItem:(UIView *)decorateItem menuscrollDirection:(JHPageMenuScrollDirection)scrollDirection decorateNumbers:(NSInteger)decorateNumbers decorateSize:(CGSize)decorateSize; 26 | 27 | /** 28 | 装饰器移动到指定下标 29 | 30 | @param index 指定下标 31 | @param animation 是否动画执行 32 | */ 33 | - (void)moveToIndex:(NSInteger)index withAnimation:(BOOL)animation; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /JHPageMenuView/JHPageDecorateView.m: -------------------------------------------------------------------------------- 1 | // 2 | // JHPageDecorateView.m 3 | // JHPageMenuViewDemo 4 | // 5 | // Created by 谭高丰 on 2017/9/23. 6 | // Copyright © 2017年 谭高丰. All rights reserved. 7 | // 8 | 9 | #import "JHPageDecorateView.h" 10 | 11 | @interface JHPageDecorateView () 12 | 13 | /** 滚动内容视图 */ 14 | @property (nonatomic, strong) UIView *progressView; 15 | /** 滚动方向 */ 16 | @property (nonatomic, assign) JHPageMenuScrollDirection scrollDirection; 17 | /** 装饰器视图 */ 18 | @property (nonatomic, weak) UIView *decorateItem; 19 | /** 装饰器个数 */ 20 | @property (nonatomic, assign) NSInteger decorateNumbers; 21 | /** 装饰器大小 */ 22 | @property (nonatomic, assign) CGSize decorateSize; 23 | /** 装饰器当前的下标 */ 24 | @property (nonatomic, assign) NSInteger selectIndex; 25 | /** 装饰器当前的位置 */ 26 | @property (nonatomic, assign) CGFloat position; 27 | 28 | 29 | /** 定时器 */ 30 | @property (nonatomic, weak) CADisplayLink *displayLink; 31 | /** 装饰器需要移动的距离绝对值(差距) */ 32 | @property (nonatomic, assign) CGFloat gap; 33 | /** 装饰器每一步需要移动的距离(步伐) */ 34 | @property (nonatomic, assign) CGFloat step; 35 | /** 装饰器移动的方向: 1代表正方向,-1代表反方向 */ 36 | @property (nonatomic, assign) int sign; 37 | 38 | @end 39 | 40 | @implementation JHPageDecorateView 41 | 42 | #pragma mark - init 43 | 44 | - (instancetype)init { 45 | self = [super init]; 46 | if (self) { 47 | [self initialization]; 48 | } 49 | return self; 50 | } 51 | 52 | - (void)initialization { 53 | [self addSubview:self.scrollView]; 54 | [self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) { 55 | make.top.leading.trailing.bottom.equalTo(self); 56 | }]; 57 | [self.scrollView addSubview:self.progressView]; 58 | } 59 | 60 | #pragma mark - getter 61 | 62 | - (UIScrollView *)scrollView { 63 | if (!_scrollView) { 64 | _scrollView = [[UIScrollView alloc] init]; 65 | _scrollView.showsHorizontalScrollIndicator = NO; 66 | _scrollView.showsVerticalScrollIndicator = NO; 67 | _scrollView.backgroundColor = [UIColor clearColor]; 68 | } 69 | return _scrollView; 70 | } 71 | 72 | - (UIView *)progressView { 73 | if (!_progressView) { 74 | _progressView = [[UIView alloc] init]; 75 | _progressView.backgroundColor = [UIColor clearColor]; 76 | } 77 | return _progressView; 78 | } 79 | 80 | #pragma mark - public 81 | 82 | - (void)setDecorateItem:(UIView *)decorateItem menuscrollDirection:(JHPageMenuScrollDirection)scrollDirection decorateNumbers:(NSInteger)decorateNumbers decorateSize:(CGSize)decorateSize { 83 | if (self.decorateItem) { 84 | [self.decorateItem removeFromSuperview]; 85 | } 86 | self.decorateNumbers = decorateNumbers; 87 | self.decorateSize = decorateSize; 88 | self.decorateItem = decorateItem; 89 | self.scrollDirection = scrollDirection; 90 | CGSize contentSize = CGSizeZero; 91 | if (self.scrollDirection == JHPageMenuScrollDirectionHorizontal) { 92 | contentSize = CGSizeMake(self.decorateSize.width * self.decorateNumbers, self.decorateSize.height); 93 | } else { 94 | contentSize = CGSizeMake(self.decorateSize.width, self.decorateSize.height * self.decorateNumbers); 95 | } 96 | self.scrollView.contentSize = contentSize; 97 | if (self.scrollDirection == JHPageMenuScrollDirectionHorizontal) { 98 | [self.progressView mas_makeConstraints:^(MASConstraintMaker *make) { 99 | make.leading.top.bottom.equalTo(self.scrollView); 100 | make.width.mas_equalTo(self.scrollView.contentSize.width); 101 | }]; 102 | } else { 103 | [self.progressView mas_makeConstraints:^(MASConstraintMaker *make) { 104 | make.leading.top.trailing.equalTo(self.scrollView); 105 | make.height.mas_equalTo(self.scrollView.contentSize.height); 106 | }]; 107 | } 108 | [self.progressView addSubview:self.decorateItem]; 109 | [self.decorateItem mas_makeConstraints:^(MASConstraintMaker *make) { 110 | make.top.leading.equalTo(self.progressView); 111 | make.width.mas_equalTo(self.decorateSize.width); 112 | make.height.mas_equalTo(self.decorateSize.height); 113 | }]; 114 | } 115 | 116 | - (void)moveToIndex:(NSInteger)index withAnimation:(BOOL)animation { 117 | if (self.selectIndex == index) { 118 | [self moveToPosition:self.position]; 119 | } else { 120 | self.gap = (self.scrollDirection == JHPageMenuScrollDirectionHorizontal ? self.decorateSize.width : self.decorateSize.height) * labs(index - self.selectIndex); 121 | self.sign = self.selectIndex > index ? -1 : 1; 122 | self.step = animation ? self.gap / 15 : self.gap; 123 | self.selectIndex = index; 124 | if (self.displayLink) { 125 | [self.displayLink invalidate]; 126 | } 127 | // 通过 CADisplayLink 来执行动画 128 | CADisplayLink *link = [CADisplayLink displayLinkWithTarget:self selector:@selector(progressChanged)]; 129 | [link addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes]; 130 | self.displayLink = link; 131 | } 132 | } 133 | 134 | #pragma mark - private 135 | 136 | - (void)progressChanged { 137 | if (self.gap > 0.00001) { 138 | self.gap -= self.step; 139 | if (self.gap < 0.0) { 140 | [self moveToPosition:self.position + self.sign * self.step]; 141 | return; 142 | } 143 | [self moveToPosition:self.position + self.sign * self.step]; 144 | } else { 145 | [self moveToPosition:self.position]; 146 | [self.displayLink invalidate]; 147 | self.displayLink = nil; 148 | } 149 | } 150 | 151 | - (void)moveToPosition:(CGFloat)pos { 152 | self.position = pos; 153 | [self.decorateItem mas_updateConstraints:^(MASConstraintMaker *make) { 154 | if (self.scrollDirection == JHPageMenuScrollDirectionHorizontal) { 155 | make.leading.mas_equalTo(pos); 156 | } else { 157 | make.top.mas_equalTo(pos); 158 | } 159 | }]; 160 | [self layoutIfNeeded]; 161 | } 162 | 163 | @end 164 | -------------------------------------------------------------------------------- /JHPageMenuView/JHPageMenuConstant.h: -------------------------------------------------------------------------------- 1 | // 2 | // JHPageMenuConstant.h 3 | // JHPageMenuViewDemo 4 | // 5 | // Created by 谭高丰 on 2017/9/21. 6 | // Copyright © 2017年 谭高丰. All rights reserved. 7 | // 8 | 9 | #ifndef JHPageMenuConstant_h 10 | #define JHPageMenuConstant_h 11 | 12 | #import 13 | static const NSInteger JHMENU_COLLECTION_VIEW_TAG = 1111; 14 | 15 | /** 16 | 菜单选中和未选中的样式 17 | */ 18 | typedef NS_ENUM(NSInteger, JHPageMenuItemStyle) { 19 | JHPageMenuItemStyleNormal, // 正常样式 20 | JHPageMenuItemStyleSelected // 选中样式 21 | }; 22 | 23 | /** 24 | 菜单滚动方向 25 | */ 26 | typedef NS_ENUM(NSInteger, JHPageMenuScrollDirection) { 27 | JHPageMenuScrollDirectionHorizontal, // 水平 28 | JHPageMenuScrollDirectionVertical // 垂直 29 | }; 30 | 31 | /** 32 | 菜单装饰的自带样式 33 | */ 34 | typedef NS_ENUM(NSInteger, JHPageDecorateStyle) { 35 | JHPageDecorateStyleDefault, // 默认样式(就是没有样式) 36 | JHPageDecorateStyleLine, // 带下划线,需要设置高度和宽度,不设置高度和宽度,默认和菜单的大小一样 37 | JHPageDecorateStyleFlood, // 涌入效果 (填充),需要设置高度和宽度,不设置高度和宽度,默认和菜单的大小一样 38 | JHPageDecorateStyleFloodHollow // 涌入效果 (空心的),需要设置高度和宽度,不设置高度和宽度,默认和菜单的大小一样 39 | }; 40 | 41 | #endif /* JHPageMenuConstant_h */ 42 | -------------------------------------------------------------------------------- /JHPageMenuView/JHPageMenuItem.h: -------------------------------------------------------------------------------- 1 | // 2 | // JHPageMenuItem.h 3 | // JHPageMenuViewDemo 4 | // 5 | // Created by 谭高丰 on 2017/9/21. 6 | // Copyright © 2017年 谭高丰. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "JHPageMenuConstant.h" 11 | @class JHPageMenuView; 12 | 13 | @interface JHPageMenuItem : UICollectionViewCell 14 | 15 | /** item的选中状态 */ 16 | @property (nonatomic, assign, getter=isItemSelected) BOOL itemSelected; 17 | 18 | /** 19 | 设置item的选中状态 20 | 21 | @param selected 是否选中 22 | @param animation 是否动画执行 23 | */ 24 | - (void)setSelected:(BOOL)selected withAnimation:(BOOL)animation; 25 | 26 | /** 27 | 初始化,推荐使用该初始化方法,内部已经帮你做了注册cell等操作 28 | 29 | @param menuView 菜单视图 30 | @param index index 31 | @return JHPageMenuItem 32 | */ 33 | + (instancetype)menuView:(JHPageMenuView *)menuView itemForIndex:(NSInteger)index; 34 | 35 | #pragma mark - 内置Item的相关属性 36 | 37 | /** 内置标题label */ 38 | @property (nonatomic, strong) UILabel *titleLabel; 39 | 40 | /** 41 | item 未选中时的样式,可以通过这个block进行设置 42 | 一般自定义 item 不建议使用这种方式设置样式,可以重写menuItemNormalStyle来自定义样式 43 | */ 44 | @property (nonatomic, copy) void(^menuItemNormalStyleBlock)(void); 45 | 46 | /** 47 | item 选中时的样式,可以通过这个block进行设置 48 | 一般自定义 item 不建议使用这种方式设置样式,可以重写menuItemNormalStyle来自定义样式 49 | */ 50 | @property (nonatomic, copy) void(^menuItemSelectedStyleBlock)(void); 51 | 52 | /** 53 | 告知item 从 选中 - 未选中 时执行的动画,可以通过这个block进行设置 54 | 一般自定义 item 不建议使用这种方式设置动画,可以重写menuItemNormalStyleAnimation来自定义样式 55 | */ 56 | @property (nonatomic, copy) void(^menuItemNormalStyleAnimationBlock)(void); 57 | 58 | /** 59 | 告知item 从 未选中 - 选中 时执行的动画,可以通过这个block进行设置 60 | 一般自定义 item 不建议使用这种方式设置动画,可以重写menuItemSelectedStyleAnimation来自定义样式 61 | */ 62 | @property (nonatomic, copy) void(^menuItemSelectedStyleAnimationBlock)(void); 63 | 64 | @end 65 | -------------------------------------------------------------------------------- /JHPageMenuView/JHPageMenuItem.m: -------------------------------------------------------------------------------- 1 | // 2 | // JHPageMenuItem.m 3 | // JHPageMenuViewDemo 4 | // 5 | // Created by 谭高丰 on 2017/9/21. 6 | // Copyright © 2017年 谭高丰. All rights reserved. 7 | // 8 | 9 | #import "JHPageMenuItem.h" 10 | #import "JHPageMenuView.h" 11 | 12 | @interface JHPageMenuItem () 13 | @end 14 | 15 | @implementation JHPageMenuItem 16 | 17 | #pragma mark - init 18 | 19 | - (void)awakeFromNib { 20 | [super awakeFromNib]; 21 | } 22 | 23 | - (instancetype)init { 24 | self = [super init]; 25 | if (self) { 26 | [self initialization]; 27 | } 28 | return self; 29 | } 30 | 31 | - (instancetype)initWithFrame:(CGRect)frame { 32 | self = [super initWithFrame:frame]; 33 | if (self) { 34 | [self initialization]; 35 | } 36 | return self; 37 | } 38 | 39 | - (instancetype)initWithCoder:(NSCoder *)coder { 40 | self = [super initWithCoder:coder]; 41 | if (self) { 42 | [self initialization]; 43 | } 44 | return self; 45 | } 46 | 47 | - (void)initialization { 48 | self.titleLabel = [[UILabel alloc] init]; 49 | self.titleLabel.font = [UIFont systemFontOfSize:15]; 50 | self.titleLabel.textColor = [UIColor grayColor]; 51 | self.titleLabel.textAlignment = NSTextAlignmentCenter; 52 | self.titleLabel.backgroundColor = [UIColor clearColor]; 53 | [self addSubview:self.titleLabel]; 54 | [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { 55 | make.top.leading.trailing.bottom.equalTo(self); 56 | }]; 57 | } 58 | 59 | + (instancetype)menuView:(JHPageMenuView *)menuView itemForIndex:(NSInteger)index { 60 | [self registerItemCollectionView:menuView.menuCollectionView]; 61 | NSIndexPath *indexPath = [NSIndexPath indexPathForItem:index inSection:0]; 62 | return [menuView.menuCollectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([self class]) forIndexPath:indexPath]; 63 | } 64 | 65 | + (void)registerItemCollectionView:(UICollectionView *)collectionView { 66 | 67 | // 如果存在对应的xib,就注册nib。如果捕获到异常,就注册class 68 | @try { 69 | [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil]; 70 | [collectionView registerNib:[UINib nibWithNibName:NSStringFromClass([self class]) bundle:nil] forCellWithReuseIdentifier:NSStringFromClass([self class])]; 71 | } @catch (NSException *exception) { 72 | [collectionView registerClass:[self class] forCellWithReuseIdentifier:NSStringFromClass([self class])]; 73 | } 74 | } 75 | 76 | #pragma mark - Overwrite 77 | 78 | - (void)menuItemNormalStyle { 79 | // 告知item未选中时的样式,自定义的菜单需要重写该方法 80 | if (self.menuItemNormalStyleBlock) { 81 | self.menuItemNormalStyleBlock(); 82 | } 83 | } 84 | 85 | - (void)menuItemSelectedStyle { 86 | // 告知item选中时的样式,自定义的菜单需要重写该方法 87 | if (self.menuItemSelectedStyleBlock) { 88 | self.menuItemSelectedStyleBlock(); 89 | } 90 | } 91 | 92 | - (void)menuItemNormalStyleAnimation { 93 | // 告知item 从 选中 - 未选中 时执行的动画,自定义的菜单如果需要执行动画,需要重写该方法 94 | if (self.menuItemNormalStyleAnimationBlock) { 95 | self.menuItemNormalStyleAnimationBlock(); 96 | } 97 | } 98 | 99 | - (void)menuItemSelectedStyleAnimation { 100 | // 告知item 从 未选中 - 选中 时执行的动画,自定义的菜单如果需要执行动画,需要重写该方法 101 | if (self.menuItemSelectedStyleAnimationBlock) { 102 | self.menuItemSelectedStyleAnimationBlock(); 103 | } 104 | } 105 | 106 | #pragma mark - Public 107 | 108 | - (void)setSelected:(BOOL)selected withAnimation:(BOOL)animation { 109 | _itemSelected = selected; 110 | if (selected) { 111 | [self menuItemSelectedStyle]; 112 | if (animation) { 113 | [self menuItemSelectedStyleAnimation]; 114 | } 115 | } else { 116 | [self menuItemNormalStyle]; 117 | if (animation) { 118 | [self menuItemNormalStyleAnimation]; 119 | } 120 | } 121 | } 122 | 123 | @end 124 | -------------------------------------------------------------------------------- /JHPageMenuView/JHPageMenuView.h: -------------------------------------------------------------------------------- 1 | // 2 | // JHPageMenuView.h 3 | // JHPageMenuViewDemo 4 | // 5 | // Created by 谭高丰 on 2017/9/21. 6 | // Copyright © 2017年 谭高丰. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "JHPageMenuConstant.h" 11 | #import "JHPageMenuItem.h" 12 | @class JHPageMenuView, JHPageDecorateView; 13 | 14 | @protocol JHPageMenuViewDataSource 15 | @required 16 | /** 17 | 告知 "JHMenuView" 需要多少个菜单 18 | 19 | @param menuView JHPageMenuView 20 | @return 菜单个数 21 | */ 22 | - (NSInteger)numbersOfItemsInMenuView:(JHPageMenuView *)menuView; 23 | 24 | /** 25 | 告知 "JHMenuView" 每个菜单的内容视图 26 | 27 | @param menuView JHPageMenuView 28 | @param index 当前需要展示内容视图的位置 29 | @return 菜单内容视图 30 | */ 31 | - (JHPageMenuItem *)menuView:(JHPageMenuView *)menuView menuCellForItemAtIndex:(NSInteger)index; 32 | 33 | @optional 34 | /** 35 | 告知 "JHMenuView" 的装饰器视图,如果实现了这个方法,且返回的装饰器视图不为nil,装饰器视图就会使用自定义的,设置的内置装饰器样式将不会生效 36 | 37 | @param menuView JHPageMenuView 38 | @return 装饰视图 39 | */ 40 | - (UIView *)decorateItemInMenuView:(JHPageMenuView *)menuView; 41 | 42 | @end 43 | 44 | @protocol JHPageMenuViewDelegate 45 | @optional 46 | 47 | /** 48 | 当点击菜单子视图的时候,你可能需要做些事情,可以在这里面实现 49 | 50 | @param menuView JHPageMenuView 51 | @param index 当前点击的菜单视图的位置 52 | */ 53 | - (void)menuView:(JHPageMenuView *)menuView didSelectIndex:(NSInteger)index; 54 | 55 | @end 56 | 57 | @interface JHPageMenuView : UIView 58 | 59 | /** 代理 */ 60 | @property (nonatomic, weak) id delegate; 61 | @property (nonatomic, weak) id dataSource; 62 | /** 菜单视图 */ 63 | @property (nonatomic, strong) UICollectionView *menuCollectionView; 64 | /** 菜单单元格大小 */ 65 | @property (nonatomic, assign) CGSize menuSize; 66 | /** 菜单滚动方向,支持垂直和水平两个方向,默认为水平方向 */ 67 | @property (nonatomic, assign) JHPageMenuScrollDirection scrollDirection; 68 | /** 内置的装饰器大小,不设置的话默认和菜单大小一致 */ 69 | @property (nonatomic, assign) CGSize decorateSize; 70 | /** 内置的装饰器样式,默认为JHPageDecorateStyleDefault,当设置了自定义的装饰器时,设置的该属性不会生效 */ 71 | @property (nonatomic, assign) JHPageDecorateStyle decorateStyle; 72 | /** 内置的装饰器样式的颜色,默认为红色 */ 73 | @property (nonatomic, strong) UIColor *decorateColor; 74 | 75 | /** 76 | 设置选中的菜单 77 | 78 | @param index 位置 79 | @param animation 装饰视图是否动画执行 80 | */ 81 | - (void)selectItemAtIndex:(NSInteger)index withAnimation:(BOOL)animation; 82 | 83 | /** 84 | 刷新数据,该方法会重新执行一遍代理方法,显示最新的数据 85 | 86 | 如果第一次初始化,先设置属性再把分页菜单添加到父视图上,这个方法可以不用执行 87 | 如果第一次初始化,先把分页菜单添加到父视图上,再设置属性,那么得执行这个方法,才能展示正确的数据 88 | 如果中途数据改变或者属性改变了,都得执行一下该方法才能展示最新的设置和数据 89 | */ 90 | - (void)reloadData; 91 | 92 | @end 93 | -------------------------------------------------------------------------------- /JHPageMenuView/JHPageMenuView.m: -------------------------------------------------------------------------------- 1 | // 2 | // JHPageMenuView.m 3 | // JHPageMenuViewDemo 4 | // 5 | // Created by 谭高丰 on 2017/9/21. 6 | // Copyright © 2017年 谭高丰. All rights reserved. 7 | // 8 | 9 | #import "JHPageMenuView.h" 10 | #import "JHPageDecorateView.h" 11 | #import "JHPageMenuItem.h" 12 | #import "JHPageDecorateBuiltInItem.h" 13 | 14 | @interface JHPageMenuView () 15 | 16 | /** collectionView布局对象 */ 17 | @property (nonatomic, strong) UICollectionViewFlowLayout *flowLayout; 18 | /** 装饰视图 */ 19 | @property (nonatomic, strong) JHPageDecorateView *decorateView; 20 | /** 菜单个数 */ 21 | @property (nonatomic, assign) NSInteger menuCount; 22 | /** 前一次选中的菜单下标 */ 23 | @property (nonatomic, assign) NSInteger beforeSelectIndex; 24 | /** 当前选中的菜单下标 */ 25 | @property (nonatomic, assign) NSInteger selectIndex; 26 | 27 | @end 28 | 29 | @implementation JHPageMenuView 30 | 31 | #pragma mark - init 32 | 33 | // 代码初始化 34 | - (instancetype)initWithFrame:(CGRect)frame { 35 | if (self = [super initWithFrame:frame]) { 36 | [self initialization]; 37 | } 38 | return self; 39 | } 40 | 41 | - (instancetype)init { 42 | if (self = [super init]) { 43 | [self initialization]; 44 | } 45 | return self; 46 | } 47 | 48 | // xib初始化 49 | - (instancetype)initWithCoder:(NSCoder *)aDecoder { 50 | if (self = [super initWithCoder:aDecoder]) { 51 | [self initialization]; 52 | } 53 | return self; 54 | } 55 | 56 | - (void)initialization { 57 | self.selectIndex = -1; 58 | self.menuSize = CGSizeZero; 59 | self.decorateSize = CGSizeZero; 60 | self.decorateStyle = JHPageDecorateStyleDefault; 61 | self.decorateColor = [UIColor redColor]; 62 | [self addSubview:self.menuCollectionView]; 63 | [self.menuCollectionView mas_makeConstraints:^(MASConstraintMaker *make) { 64 | make.top.leading.trailing.bottom.equalTo(self); 65 | }]; 66 | } 67 | 68 | #pragma mark - setter 69 | 70 | - (void)setScrollDirection:(JHPageMenuScrollDirection)scrollDirection { 71 | _scrollDirection = scrollDirection; 72 | self.flowLayout.scrollDirection = scrollDirection == JHPageMenuScrollDirectionHorizontal ? UICollectionViewScrollDirectionHorizontal : UICollectionViewScrollDirectionVertical; 73 | } 74 | 75 | #pragma mark - getter 76 | 77 | - (UICollectionView *)menuCollectionView { 78 | if (!_menuCollectionView) { 79 | _menuCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:self.flowLayout]; 80 | _menuCollectionView.tag = JHMENU_COLLECTION_VIEW_TAG; 81 | _menuCollectionView.backgroundColor = [UIColor clearColor]; 82 | _menuCollectionView.showsHorizontalScrollIndicator = NO; 83 | _menuCollectionView.showsVerticalScrollIndicator = NO; 84 | _menuCollectionView.delegate = self; 85 | _menuCollectionView.dataSource = self; 86 | } 87 | return _menuCollectionView; 88 | } 89 | 90 | - (UICollectionViewFlowLayout *)flowLayout { 91 | if (!_flowLayout) { 92 | _flowLayout = [[UICollectionViewFlowLayout alloc] init]; 93 | _flowLayout.minimumLineSpacing = 0; 94 | _flowLayout.scrollDirection = self.scrollDirection == JHPageMenuScrollDirectionHorizontal ? UICollectionViewScrollDirectionHorizontal : UICollectionViewScrollDirectionVertical; 95 | } 96 | return _flowLayout; 97 | } 98 | 99 | - (NSInteger)menuCount { 100 | NSInteger menuCount = [self.dataSource numbersOfItemsInMenuView:self]; 101 | if (menuCount != 0 && self.decorateView == nil) { 102 | [self addDecorateView]; 103 | } 104 | return menuCount; 105 | } 106 | 107 | #pragma mark UICollectionViewDelegateFlowLayout 108 | 109 | - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { 110 | return self.menuSize; 111 | } 112 | 113 | #pragma mark - UICollectionViewDataSource 114 | 115 | - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { 116 | return self.menuCount; 117 | } 118 | 119 | - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { 120 | JHPageMenuItem *item = [self.dataSource menuView:self menuCellForItemAtIndex:indexPath.row]; 121 | if (indexPath.row == self.selectIndex) { 122 | [item setSelected:YES withAnimation:YES]; 123 | } else { 124 | if (indexPath.row == self.beforeSelectIndex) { 125 | [item setSelected:NO withAnimation:YES]; 126 | } else { 127 | [item setSelected:NO withAnimation:NO]; 128 | } 129 | } 130 | return item; 131 | } 132 | 133 | #pragma mark - UICollectionViewDelegate 134 | 135 | - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { 136 | [self selectItemAtIndex:indexPath.row withAnimation:YES]; 137 | } 138 | 139 | #pragma makr - UIScrollViewDelegate 140 | 141 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView { 142 | // 菜单视图滚动的时候,装饰视图也要跟着一起滚动 143 | if (scrollView.tag == JHMENU_COLLECTION_VIEW_TAG) { 144 | [self.decorateView.scrollView setContentOffset:scrollView.contentOffset]; 145 | } 146 | } 147 | 148 | #pragma mark - Private 149 | 150 | - (void)addDecorateView { 151 | 152 | UIView *decorateItem = nil; 153 | if ([self.dataSource respondsToSelector:@selector(decorateItemInMenuView:)] && [self.dataSource decorateItemInMenuView:self]) { 154 | decorateItem = [self.dataSource decorateItemInMenuView:self]; 155 | } else { 156 | if (self.decorateStyle == JHPageDecorateStyleDefault) return; 157 | 158 | JHPageDecorateBuiltInItem *builtInItem = [[JHPageDecorateBuiltInItem alloc] init]; 159 | builtInItem.scrollDirection = self.scrollDirection; 160 | builtInItem.decorateSize = self.decorateSize.width == 0 ? self.menuSize : self.decorateSize; 161 | builtInItem.decorateColor = self.decorateColor; 162 | builtInItem.decorateStyle = self.decorateStyle; 163 | decorateItem = builtInItem; 164 | } 165 | JHPageDecorateView *decorateView = [[JHPageDecorateView alloc] init]; 166 | [decorateView setDecorateItem:decorateItem menuscrollDirection:self.scrollDirection decorateNumbers:[self.dataSource numbersOfItemsInMenuView:self] decorateSize:self.menuSize]; 167 | self.decorateView = decorateView; 168 | [self insertSubview:self.decorateView atIndex:0]; 169 | [self.decorateView mas_makeConstraints:^(MASConstraintMaker *make) { 170 | make.top.leading.trailing.bottom.equalTo(self); 171 | }]; 172 | } 173 | 174 | - (void)willMoveToSuperview:(UIView *)newSuperview { 175 | if (newSuperview == nil) { 176 | return; 177 | } 178 | dispatch_async(dispatch_get_main_queue(), ^{ 179 | [self selectItemAtIndex:self.selectIndex withAnimation:NO]; 180 | }); 181 | // 182 | // //[self selectItemAtIndex:self.selectIndex withAnimation:NO]; 183 | // dispatch_async(dispatch_get_main_queue(), ^{ 184 | // // 当有设置初始菜单下标的时候,等待主队列空闲再执行该方法 185 | // 186 | //// if (self.selectIndex == 0) { 187 | //// if ([self.delegate respondsToSelector:@selector(menuView:didSelectIndex:)]) { 188 | //// [self.delegate menuView:self didSelectIndex:0]; 189 | //// } 190 | //// } 191 | // }); 192 | } 193 | 194 | // 让选中的item位于中间 195 | - (void)refreshContentOffsetItemFrame:(CGRect)frame { 196 | 197 | CGSize contentSize = self.menuCollectionView.contentSize; 198 | if (self.scrollDirection == JHPageMenuScrollDirectionHorizontal) { 199 | if (contentSize.width <= self.menuCollectionView.frame.size.width) { return; } 200 | 201 | CGFloat itemX = frame.origin.x; 202 | CGFloat itemWith = self.menuCollectionView.frame.size.width; 203 | if (itemX > itemWith/2) { 204 | CGFloat targetX; 205 | if ((contentSize.width-itemX) <= itemWith/2) { 206 | targetX = contentSize.width - itemWith; 207 | } else { 208 | targetX = itemX - itemWith/2 + frame.size.width/2; 209 | } 210 | if (targetX + itemWith > contentSize.width) { 211 | targetX = contentSize.width - itemWith; 212 | } 213 | [self.menuCollectionView setContentOffset:CGPointMake(targetX, 0) animated:YES]; 214 | } else { 215 | [self.menuCollectionView setContentOffset:CGPointMake(0, 0) animated:YES]; 216 | } 217 | } else { 218 | if (contentSize.height <= self.menuCollectionView.frame.size.height) { return; } 219 | 220 | CGFloat itemY = frame.origin.y; 221 | CGFloat itemHeight = self.menuCollectionView.frame.size.height; 222 | if (itemY > itemHeight/2) { 223 | CGFloat targetY; 224 | if ((contentSize.height-itemY) <= itemHeight/2) { 225 | targetY = contentSize.height - itemHeight; 226 | } else { 227 | targetY = itemY - itemHeight/2 + frame.size.height/2; 228 | } 229 | if (targetY + itemHeight > contentSize.height) { 230 | targetY = contentSize.height - itemHeight; 231 | } 232 | [self.menuCollectionView setContentOffset:CGPointMake(0, targetY) animated:YES]; 233 | } else { 234 | [self.menuCollectionView setContentOffset:CGPointMake(0, 0) animated:YES]; 235 | } 236 | } 237 | } 238 | 239 | #pragma mark - Public 240 | 241 | - (void)selectItemAtIndex:(NSInteger)index withAnimation:(BOOL)animation { 242 | 243 | if (index == -1) { 244 | index = 0; 245 | } 246 | 247 | NSIndexPath *selectIndexPath = [NSIndexPath indexPathForItem:index inSection:0]; 248 | JHPageMenuItem *item = [self.dataSource menuView:self menuCellForItemAtIndex:selectIndexPath.row]; 249 | if (!item) { return; } 250 | 251 | if (index != self.selectIndex && [self.delegate respondsToSelector:@selector(menuView:didSelectIndex:)]) { 252 | [self.delegate menuView:self didSelectIndex:selectIndexPath.row]; 253 | self.beforeSelectIndex = self.selectIndex == -1 ? 0 : self.selectIndex; 254 | self.selectIndex = index; 255 | [self.menuCollectionView reloadData]; 256 | } 257 | if (self.decorateView) { 258 | [self.decorateView moveToIndex:index withAnimation:animation]; 259 | } 260 | [self refreshContentOffsetItemFrame:item.frame]; 261 | } 262 | 263 | - (void)reloadData { 264 | if (self.decorateView) { 265 | UIView *decorateItem = nil; 266 | if ([self.dataSource respondsToSelector:@selector(decorateItemInMenuView:)] && [self.dataSource decorateItemInMenuView:self]) { 267 | decorateItem = [self.dataSource decorateItemInMenuView:self]; 268 | } else { 269 | if (self.decorateStyle == JHPageDecorateStyleDefault) return; 270 | 271 | JHPageDecorateBuiltInItem *builtInItem = [[JHPageDecorateBuiltInItem alloc] init]; 272 | builtInItem.scrollDirection = self.scrollDirection; 273 | builtInItem.decorateSize = self.decorateSize.width == 0 ? self.menuSize : self.decorateSize; 274 | builtInItem.decorateColor = self.decorateColor; 275 | builtInItem.decorateStyle = self.decorateStyle; 276 | decorateItem = builtInItem; 277 | } 278 | [self.decorateView setDecorateItem:decorateItem menuscrollDirection:self.scrollDirection decorateNumbers:[self.dataSource numbersOfItemsInMenuView:self] decorateSize:self.menuSize]; 279 | } 280 | if (self.selectIndex > (self.menuCount - 1)) { 281 | self.selectIndex = 0; 282 | } 283 | [self selectItemAtIndex:self.selectIndex withAnimation:NO]; 284 | if ([self.delegate respondsToSelector:@selector(menuView:didSelectIndex:)]) { 285 | [self.delegate menuView:self didSelectIndex:self.selectIndex]; 286 | } 287 | [self.menuCollectionView reloadData]; 288 | } 289 | 290 | @end 291 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemo.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // JHPageMenuViewDemo 4 | // 5 | // Created by 谭高丰 on 2017/9/21. 6 | // Copyright © 2017年 谭高丰. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // JHPageMenuViewDemo 4 | // 5 | // Created by 谭高丰 on 2017/9/21. 6 | // Copyright © 2017年 谭高丰. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "MenuDirectionViewController.h" 11 | 12 | @interface AppDelegate () 13 | 14 | @end 15 | 16 | @implementation AppDelegate 17 | 18 | 19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 20 | // Override point for customization after application launch. 21 | MenuDirectionViewController *rootVc = [[MenuDirectionViewController alloc] init]; 22 | UINavigationController *navC = [[UINavigationController alloc] initWithRootViewController:rootVc]; 23 | navC.navigationBar.translucent = NO; 24 | self.window.rootViewController = navC; 25 | return YES; 26 | } 27 | 28 | 29 | - (void)applicationWillResignActive:(UIApplication *)application { 30 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 31 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 32 | } 33 | 34 | 35 | - (void)applicationDidEnterBackground:(UIApplication *)application { 36 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 37 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 38 | } 39 | 40 | 41 | - (void)applicationWillEnterForeground:(UIApplication *)application { 42 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 43 | } 44 | 45 | 46 | - (void)applicationDidBecomeActive:(UIApplication *)application { 47 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 48 | } 49 | 50 | 51 | - (void)applicationWillTerminate:(UIApplication *)application { 52 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 53 | } 54 | 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemo/Assets.xcassets/triangle_left.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "triangle_left.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemo/Assets.xcassets/triangle_left.imageset/triangle_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaktangf/JHPageMenuView/8a2438a26e41c749ceac4e6b4d3e675daa59750b/JHPageMenuViewDemo/JHPageMenuViewDemo/Assets.xcassets/triangle_left.imageset/triangle_left.png -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemo/Assets.xcassets/triangle_top.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "Triangle.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemo/Assets.xcassets/triangle_top.imageset/Triangle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaktangf/JHPageMenuView/8a2438a26e41c749ceac4e6b4d3e675daa59750b/JHPageMenuViewDemo/JHPageMenuViewDemo/Assets.xcassets/triangle_top.imageset/Triangle.png -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemo/View/CustomDecorateItem.h: -------------------------------------------------------------------------------- 1 | // 2 | // CustomDecorateItem.h 3 | // JHPageMenuViewDemo 4 | // 5 | // Created by 谭高丰 on 2017/9/23. 6 | // Copyright © 2017年 谭高丰. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CustomDecorateItem : UIView 12 | 13 | @property (weak, nonatomic) IBOutlet UIImageView *imgView; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemo/View/CustomDecorateItem.m: -------------------------------------------------------------------------------- 1 | // 2 | // CustomDecorateItem.m 3 | // JHPageMenuViewDemo 4 | // 5 | // Created by 谭高丰 on 2017/9/23. 6 | // Copyright © 2017年 谭高丰. All rights reserved. 7 | // 8 | 9 | #import "CustomDecorateItem.h" 10 | 11 | @implementation CustomDecorateItem 12 | 13 | /* 14 | // Only override drawRect: if you perform custom drawing. 15 | // An empty implementation adversely affects performance during animation. 16 | - (void)drawRect:(CGRect)rect { 17 | // Drawing code 18 | } 19 | */ 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemo/View/CustomDecorateItem.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemo/View/CustomMenuItem.h: -------------------------------------------------------------------------------- 1 | // 2 | // CustomMenuItem.h 3 | // JHPageMenuViewDemo 4 | // 5 | // Created by 谭高丰 on 2017/9/24. 6 | // Copyright © 2017年 谭高丰. All rights reserved. 7 | // 8 | 9 | #import "JHPageMenuItem.h" 10 | 11 | @interface CustomMenuItem : JHPageMenuItem 12 | 13 | @property (weak, nonatomic) IBOutlet UILabel *lbTitle; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemo/View/CustomMenuItem.m: -------------------------------------------------------------------------------- 1 | // 2 | // CustomMenuItem.m 3 | // JHPageMenuViewDemo 4 | // 5 | // Created by 谭高丰 on 2017/9/24. 6 | // Copyright © 2017年 谭高丰. All rights reserved. 7 | // 8 | 9 | #import "CustomMenuItem.h" 10 | 11 | @interface CustomMenuItem () 12 | @property (weak, nonatomic) IBOutlet UIView *markView; 13 | @end 14 | 15 | @implementation CustomMenuItem 16 | 17 | - (void)awakeFromNib { 18 | [super awakeFromNib]; 19 | } 20 | 21 | // 样式 22 | - (void)menuItemNormalStyle { 23 | self.lbTitle.textColor = [UIColor grayColor]; 24 | self.markView.backgroundColor = [UIColor grayColor]; 25 | } 26 | 27 | - (void)menuItemSelectedStyle { 28 | self.lbTitle.textColor = [UIColor redColor]; 29 | self.markView.backgroundColor = [UIColor redColor]; 30 | } 31 | 32 | // 动画 33 | - (void)menuItemNormalStyleAnimation { 34 | [UIView animateWithDuration:.3 animations:^{ 35 | self.transform = CGAffineTransformIdentity; 36 | }]; 37 | } 38 | 39 | - (void)menuItemSelectedStyleAnimation { 40 | [UIView animateWithDuration:.3 animations:^{ 41 | self.transform = CGAffineTransformMakeScale(1.1, 1.1); 42 | }]; 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemo/View/CustomMenuItem.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemo/ViewController/MenuDirectionViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // JHMenuViewDemo 4 | // 5 | // Created by 谭高丰 on 2017/9/20. 6 | // Copyright © 2017年 谭高丰. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface MenuDirectionViewController : UITableViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemo/ViewController/MenuDirectionViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // JHMenuViewDemo 4 | // 5 | // Created by 谭高丰 on 2017/9/20. 6 | // Copyright © 2017年 谭高丰. All rights reserved. 7 | // 8 | 9 | #import "MenuDirectionViewController.h" 10 | #import "MenuStylesViewController.h" 11 | #import "NavTabMenuViewController.h" 12 | #import "PageControllerStyleViewController.h" 13 | 14 | 15 | static NSString *MENU_DIRECTION_IDENTIFIER = @"MenuDirectionCell"; 16 | 17 | @interface MenuDirectionViewController () 18 | @property (nonatomic, copy) NSArray *datas; 19 | 20 | @end 21 | 22 | @implementation MenuDirectionViewController 23 | 24 | - (void)viewDidLoad { 25 | [super viewDidLoad]; 26 | self.title = @"菜单类型"; 27 | [self setupData]; 28 | [self setupView]; 29 | } 30 | 31 | - (void)setupData { 32 | self.datas = @[@"横向菜单",@"竖向菜单",@"网易选项卡",@"JHPageController"]; 33 | } 34 | 35 | - (void)setupView { 36 | self.view.backgroundColor = [UIColor whiteColor]; 37 | [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:MENU_DIRECTION_IDENTIFIER]; 38 | [self.tableView reloadData]; 39 | } 40 | 41 | 42 | #pragma mark - UITableViewDataSource 43 | 44 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 45 | return self.datas.count; 46 | } 47 | 48 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 49 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MENU_DIRECTION_IDENTIFIER forIndexPath:indexPath]; 50 | cell.textLabel.text = self.datas[indexPath.row]; 51 | return cell; 52 | } 53 | 54 | #pragma mark - UITableViewDelegate 55 | 56 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 57 | if (indexPath.row == 2) { 58 | NavTabMenuViewController *tabMenuVc = [[NavTabMenuViewController alloc] init]; 59 | [self.navigationController pushViewController:tabMenuVc animated:YES]; 60 | } else if (indexPath.row == 3) { 61 | PageControllerStyleViewController *pageStyleVc = [[PageControllerStyleViewController alloc] init]; 62 | [self.navigationController pushViewController:pageStyleVc animated:YES]; 63 | } else { 64 | MenuStylesViewController *styleVc = [[MenuStylesViewController alloc] init]; 65 | styleVc.menuScrollDirection = indexPath.row == 0 ? JHPageMenuScrollDirectionHorizontal : JHPageMenuScrollDirectionVertical; 66 | [self.navigationController pushViewController:styleVc animated:YES]; 67 | } 68 | } 69 | 70 | - (void)didReceiveMemoryWarning { 71 | [super didReceiveMemoryWarning]; 72 | } 73 | 74 | @end 75 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemo/ViewController/MenuStylesViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MenuStylesViewController.h 3 | // JHPageMenuViewDemo 4 | // 5 | // Created by 谭高丰 on 2017/9/23. 6 | // Copyright © 2017年 谭高丰. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "JHPageMenuView.h" 11 | 12 | @interface MenuStylesViewController : UITableViewController 13 | 14 | /** 15 | 菜单的滚动方向 16 | */ 17 | @property (nonatomic, assign) JHPageMenuScrollDirection menuScrollDirection; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemo/ViewController/MenuStylesViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // MenuStylesViewController.m 3 | // JHPageMenuViewDemo 4 | // 5 | // Created by 谭高丰 on 2017/9/23. 6 | // Copyright © 2017年 谭高丰. All rights reserved. 7 | // 8 | 9 | #import "MenuStylesViewController.h" 10 | #import "MenuViewController.h" 11 | 12 | static NSString *MENU_STYLE_IDENTIFIER = @"MenuStyleCell"; 13 | 14 | @interface MenuStylesViewController () 15 | @property (nonatomic, copy) NSArray *datas; 16 | @end 17 | 18 | @implementation MenuStylesViewController 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | self.title = @"菜单样式"; 23 | [self setupData]; 24 | [self setupView]; 25 | } 26 | 27 | - (void)setupData { 28 | self.datas = @[@{@"name":@"JHPageDecorateStyleDefault", @"style":@(JHPageDecorateStyleDefault)}, 29 | @{@"name":@"JHPageDecorateStyleLine", @"style":@(JHPageDecorateStyleLine)}, 30 | @{@"name":@"JHPageDecorateStyleFlood", @"style":@(JHPageDecorateStyleFlood)}, 31 | @{@"name":@"JHPageDecorateStyleFloodHollow", @"style":@(JHPageDecorateStyleFloodHollow)}, 32 | @{@"name":@"自定义菜单", @"style":@(11)}, 33 | @{@"name":@"自定义装饰器", @"style":@(22)}]; 34 | } 35 | 36 | - (void)setupView { 37 | self.view.backgroundColor = [UIColor whiteColor]; 38 | [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:MENU_STYLE_IDENTIFIER]; 39 | [self.tableView reloadData]; 40 | } 41 | 42 | - (void)didReceiveMemoryWarning { 43 | [super didReceiveMemoryWarning]; 44 | } 45 | 46 | #pragma mark - Table view data source 47 | 48 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 49 | return self.datas.count; 50 | } 51 | 52 | 53 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 54 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MENU_STYLE_IDENTIFIER forIndexPath:indexPath]; 55 | cell.textLabel.text = [self.datas[indexPath.row] objectForKey:@"name"]; 56 | return cell; 57 | } 58 | 59 | #pragma mark - UITableViewDelegate 60 | 61 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 62 | [tableView deselectRowAtIndexPath:indexPath animated:YES]; 63 | MenuViewController *vc = [[MenuViewController alloc] init]; 64 | vc.menuScrollDirection = self.menuScrollDirection; 65 | if ([[self.datas[indexPath.row] objectForKey:@"style"] integerValue] == 11) { 66 | vc.isCustomMenu = YES; 67 | vc.decorateStyle = JHPageDecorateStyleLine; 68 | } else if ([[self.datas[indexPath.row] objectForKey:@"style"] integerValue] == 22) { 69 | vc.isCustomDecorate = YES; 70 | } else { 71 | vc.decorateStyle = [[self.datas[indexPath.row] objectForKey:@"style"] integerValue]; 72 | } 73 | [self.navigationController pushViewController:vc animated:YES]; 74 | } 75 | 76 | 77 | @end 78 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemo/ViewController/MenuViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MenuViewController.h 3 | // JHMenuViewDemo 4 | // 5 | // Created by 谭高丰 on 2017/9/20. 6 | // Copyright © 2017年 谭高丰. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "JHPageMenuView.h" 11 | 12 | @interface MenuViewController : UIViewController 13 | 14 | /** 15 | 菜单的滚动方向 16 | */ 17 | @property (nonatomic, assign) JHPageMenuScrollDirection menuScrollDirection; 18 | 19 | /** 20 | 装饰视图的样式 21 | */ 22 | @property (nonatomic, assign) JHPageDecorateStyle decorateStyle; 23 | 24 | /** 25 | 是否使用自定义的装饰视图 26 | */ 27 | @property (nonatomic, assign) BOOL isCustomDecorate; 28 | 29 | /** 30 | 是否使用自定义的菜单 31 | */ 32 | @property (nonatomic, assign) BOOL isCustomMenu; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemo/ViewController/MenuViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // MenuViewController.m 3 | // JHMenuViewDemo 4 | // 5 | // Created by 谭高丰 on 2017/9/20. 6 | // Copyright © 2017年 谭高丰. All rights reserved. 7 | // 8 | 9 | #import "MenuViewController.h" 10 | #import "CustomMenuItem.h" 11 | #import "CustomDecorateItem.h" 12 | #import 13 | 14 | 15 | @interface MenuViewController () 16 | @property (nonatomic, strong) JHPageMenuView *menuView; 17 | @property (nonatomic, strong) NSMutableArray *datas; 18 | @property (nonatomic, assign) BOOL animation; 19 | @end 20 | 21 | @implementation MenuViewController 22 | 23 | - (void)viewDidLoad { 24 | [super viewDidLoad]; 25 | [self setupData]; 26 | [self setupView]; 27 | } 28 | 29 | - (void)setupData { 30 | self.datas = [NSMutableArray array]; 31 | for (int i = 0; i < 20; i ++) { 32 | [self.datas addObject:[NSString stringWithFormat:@"标题%i",i + 1]]; 33 | } 34 | } 35 | 36 | - (void)setupView { 37 | self.view.backgroundColor = [UIColor whiteColor]; 38 | UIBarButtonItem *itemOne = [[UIBarButtonItem alloc] initWithTitle:@"刷新内容" style:UIBarButtonItemStylePlain target:self action:@selector(refreshData)]; 39 | UIBarButtonItem *itemTwo = [[UIBarButtonItem alloc] initWithTitle:@"切换下标" style:UIBarButtonItemStylePlain target:self action:@selector(switchIndex)]; 40 | UIBarButtonItem *itemThree = [[UIBarButtonItem alloc] initWithTitle:@"是否动画" style:UIBarButtonItemStylePlain target:self action:@selector(switchAnimation)]; 41 | self.navigationItem.rightBarButtonItems = @[itemOne,itemTwo,itemThree]; 42 | [self.view addSubview:self.menuView]; 43 | if (self.menuScrollDirection == JHPageMenuScrollDirectionHorizontal) { 44 | [self.menuView mas_makeConstraints:^(MASConstraintMaker *make) { 45 | make.top.leading.trailing.equalTo(self.view); 46 | make.height.mas_equalTo(self.isCustomMenu ? 100 : 50); 47 | }]; 48 | } else { 49 | [self.menuView mas_makeConstraints:^(MASConstraintMaker *make) { 50 | make.top.leading.bottom.equalTo(self.view); 51 | make.width.mas_equalTo(self.isCustomMenu ? 100 : 80); 52 | }]; 53 | } 54 | } 55 | 56 | #pragma mark - getter 57 | 58 | - (JHPageMenuView *)menuView { 59 | if (!_menuView) { 60 | _menuView = [[JHPageMenuView alloc] init]; 61 | _menuView.backgroundColor = [UIColor groupTableViewBackgroundColor]; 62 | _menuView.delegate = self; 63 | _menuView.dataSource = self; 64 | _menuView.scrollDirection = self.menuScrollDirection; 65 | _menuView.menuSize = self.isCustomMenu ? CGSizeMake(100, 100) : CGSizeMake(80.135, 50); 66 | switch (self.decorateStyle) { 67 | case JHPageDecorateStyleDefault: 68 | break; 69 | case JHPageDecorateStyleLine: 70 | _menuView.decorateStyle = JHPageDecorateStyleLine; 71 | if (self.isCustomMenu) { 72 | _menuView.decorateSize = self.menuScrollDirection == JHPageMenuScrollDirectionHorizontal ? CGSizeMake(90, 2) : CGSizeMake(2, 90); 73 | } else { 74 | _menuView.decorateSize = self.menuScrollDirection == JHPageMenuScrollDirectionHorizontal ? CGSizeMake(40, 2) : CGSizeMake(2, 40); 75 | } 76 | 77 | break; 78 | case JHPageDecorateStyleFlood: 79 | _menuView.decorateStyle = JHPageDecorateStyleFlood; 80 | _menuView.decorateSize = CGSizeMake(70, 30); 81 | break; 82 | case JHPageDecorateStyleFloodHollow: 83 | _menuView.decorateStyle = JHPageDecorateStyleFloodHollow; 84 | _menuView.decorateSize = CGSizeMake(70, 30); 85 | break; 86 | } 87 | } 88 | return _menuView; 89 | } 90 | 91 | #pragma mark - JHMenuViewDataSource 92 | 93 | - (NSInteger)numbersOfItemsInMenuView:(JHPageMenuView *)menuView { 94 | return self.datas.count; 95 | } 96 | 97 | - (JHPageMenuItem *)menuView:(JHPageMenuView *)menuView menuCellForItemAtIndex:(NSInteger)index { 98 | if (self.isCustomMenu) { 99 | CustomMenuItem *item = [CustomMenuItem menuView:menuView itemForIndex:index]; 100 | item.lbTitle.text = self.datas[index]; 101 | return item; 102 | } else { 103 | JHPageMenuItem *item = [JHPageMenuItem menuView:menuView itemForIndex:index]; 104 | item.titleLabel.text = self.datas[index]; 105 | __weak typeof(self)weakSelf = self; 106 | __weak typeof(item)weakItem = item; 107 | // 样式 108 | item.menuItemNormalStyleBlock = ^{ 109 | weakItem.titleLabel.textColor = weakSelf.decorateStyle == JHPageDecorateStyleFlood ? [UIColor redColor] : [UIColor grayColor]; 110 | }; 111 | item.menuItemSelectedStyleBlock = ^{ 112 | weakItem.titleLabel.textColor = weakSelf.decorateStyle == JHPageDecorateStyleFlood ? [UIColor whiteColor] : [UIColor redColor]; 113 | }; 114 | // 动画 115 | item.menuItemNormalStyleAnimationBlock = ^{ 116 | if (weakSelf.animation) { 117 | [UIView animateWithDuration:.3 animations:^{ 118 | weakItem.transform = CGAffineTransformMakeScale(0.9, 0.9); 119 | }]; 120 | } 121 | }; 122 | item.menuItemSelectedStyleAnimationBlock = ^{ 123 | if (self.animation) { 124 | [UIView animateWithDuration:.3 animations:^{ 125 | weakItem.transform = CGAffineTransformMakeScale(1.1, 1.1); 126 | }]; 127 | } 128 | }; 129 | return item; 130 | } 131 | } 132 | 133 | - (UIView *)decorateItemInMenuView:(JHPageMenuView *)menuView { 134 | if (self.isCustomDecorate) { 135 | CustomDecorateItem *item = [[[NSBundle mainBundle] loadNibNamed:@"CustomDecorateItem" owner:nil options:nil] firstObject]; 136 | if (self.menuScrollDirection == JHPageMenuScrollDirectionHorizontal) { 137 | item.imgView.image = [UIImage imageNamed:@"triangle_top"]; 138 | [item.imgView mas_makeConstraints:^(MASConstraintMaker *make) { 139 | make.bottom.equalTo(item); 140 | make.width.mas_equalTo(15); 141 | make.height.mas_equalTo(10); 142 | make.centerX.equalTo(item); 143 | }]; 144 | } else { 145 | item.imgView.image = [UIImage imageNamed:@"triangle_left"]; 146 | [item.imgView mas_makeConstraints:^(MASConstraintMaker *make) { 147 | make.trailing.equalTo(item); 148 | make.width.mas_equalTo(10); 149 | make.height.mas_equalTo(15); 150 | make.centerY.equalTo(item); 151 | }]; 152 | } 153 | return item; 154 | } 155 | return nil; 156 | } 157 | 158 | #pragma mark - JHMenuViewDelegate 159 | 160 | - (void)menuView:(JHPageMenuView *)menuView didSelectIndex:(NSInteger)index { 161 | NSLog(@"当前选中的菜单 = %ld",index); 162 | } 163 | 164 | #pragma mark - action 165 | 166 | - (void)refreshData { 167 | [self.datas removeAllObjects]; 168 | for (int i = 0; i < 20; i ++) { 169 | [self.datas addObject:[NSString stringWithFormat:@"新标题%i",i + 1]]; 170 | } 171 | [self.menuView reloadData]; 172 | } 173 | 174 | - (void)switchIndex { 175 | [self.menuView selectItemAtIndex:5 withAnimation:YES]; 176 | } 177 | 178 | - (void)switchAnimation { 179 | self.animation = !self.animation; 180 | [self.menuView reloadData]; 181 | } 182 | 183 | - (void)didReceiveMemoryWarning { 184 | [super didReceiveMemoryWarning]; 185 | } 186 | 187 | @end 188 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemo/ViewController/NavTabMenuViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // NavTabMenuViewController.h 3 | // JHPageMenuViewDemo 4 | // 5 | // Created by 谭高丰 on 2017/9/25. 6 | // Copyright © 2017年 谭高丰. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NavTabMenuViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemo/ViewController/NavTabMenuViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // NavTabMenuViewController.m 3 | // JHPageMenuViewDemo 4 | // 5 | // Created by 谭高丰 on 2017/9/25. 6 | // Copyright © 2017年 谭高丰. All rights reserved. 7 | // 8 | 9 | #import "NavTabMenuViewController.h" 10 | #import "JHPageMenuView.h" 11 | #import 12 | 13 | @interface NavTabMenuViewController () 14 | @property (nonatomic, strong) JHPageMenuView *menuView; 15 | @property (nonatomic, copy) NSArray *datas; 16 | @end 17 | 18 | @implementation NavTabMenuViewController 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | [self setupData]; 23 | [self setupView]; 24 | } 25 | 26 | - (void)setupData { 27 | self.datas = @[@"标题1",@"标题2"]; 28 | } 29 | 30 | - (void)setupView { 31 | self.view.backgroundColor = [UIColor whiteColor]; 32 | [self.menuView setFrame:CGRectMake(0, 0, 160, 30)]; 33 | self.navigationItem.titleView = self.menuView; 34 | } 35 | 36 | - (void)didReceiveMemoryWarning { 37 | [super didReceiveMemoryWarning]; 38 | } 39 | 40 | #pragma mark - getter 41 | 42 | - (JHPageMenuView *)menuView { 43 | if (!_menuView) { 44 | _menuView = [[JHPageMenuView alloc] init]; 45 | _menuView.backgroundColor = [UIColor whiteColor]; 46 | _menuView.layer.cornerRadius = 15.0; 47 | _menuView.layer.borderWidth = 1.0; 48 | _menuView.layer.borderColor = [UIColor redColor].CGColor; 49 | _menuView.menuSize = CGSizeMake(80, 30); 50 | _menuView.decorateStyle = JHPageDecorateStyleFlood; 51 | _menuView.decorateColor = [UIColor redColor]; 52 | _menuView.delegate = self; 53 | _menuView.dataSource = self; 54 | } 55 | return _menuView; 56 | } 57 | 58 | #pragma mark - JHMenuViewDataSource 59 | 60 | - (NSInteger)numbersOfItemsInMenuView:(JHPageMenuView *)menuView { 61 | return self.datas.count; 62 | } 63 | 64 | - (JHPageMenuItem *)menuView:(JHPageMenuView *)menuView menuCellForItemAtIndex:(NSInteger)index { 65 | JHPageMenuItem *item = [JHPageMenuItem menuView:menuView itemForIndex:index]; 66 | item.titleLabel.text = self.datas[index]; 67 | __weak typeof(item)weakItem = item; 68 | item.menuItemNormalStyleBlock = ^{ 69 | weakItem.titleLabel.textColor = [UIColor redColor]; 70 | }; 71 | item.menuItemSelectedStyleBlock = ^{ 72 | weakItem.titleLabel.textColor = [UIColor whiteColor]; 73 | }; 74 | return item; 75 | } 76 | 77 | #pragma mark - JHMenuViewDelegate 78 | 79 | - (void)menuView:(JHPageMenuView *)menuView didSelectIndex:(NSInteger)index { 80 | NSLog(@"当前选中的菜单 = %ld",index); 81 | } 82 | 83 | @end 84 | 85 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemo/ViewController/PageControllerStyleViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // PageControllerStyleViewController.h 3 | // JHPageMenuViewDemo 4 | // 5 | // Created by 谭高丰 on 2017/9/26. 6 | // Copyright © 2017年 谭高丰. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PageControllerStyleViewController : UITableViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemo/ViewController/PageControllerStyleViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // PageControllerStyleViewController.m 3 | // JHPageMenuViewDemo 4 | // 5 | // Created by 谭高丰 on 2017/9/26. 6 | // Copyright © 2017年 谭高丰. All rights reserved. 7 | // 8 | 9 | #import "PageControllerStyleViewController.h" 10 | #import "PageControllerViewController.h" 11 | 12 | static NSString *PAGECONTROLLER_STYLE_IDENTIFIER = @"PageControllerStyleCell"; 13 | 14 | @interface PageControllerStyleViewController () 15 | @property (nonatomic, copy) NSArray *datas; 16 | @end 17 | 18 | @implementation PageControllerStyleViewController 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | self.title = @"菜单样式"; 23 | [self setupData]; 24 | [self setupView]; 25 | } 26 | 27 | - (void)setupData { 28 | self.datas = @[@{@"name":@"JHPageMenuLocationStyleTop", @"style":@(JHPageMenuLocationStyleTop)}, 29 | @{@"name":@"JHPageMenuLocationStyleLeft", @"style":@(JHPageMenuLocationStyleLeft)}, 30 | @{@"name":@"JHPageMenuLocationStyleBottom", @"style":@(JHPageMenuLocationStyleBottom)}, 31 | @{@"name":@"JHPageMenuLocationStyleRight", @"style":@(JHPageMenuLocationStyleRight)}, 32 | @{@"name":@"JHPageMenuLocationStyleNavBar", @"style":@(JHPageMenuLocationStyleNavBar)}]; 33 | } 34 | 35 | - (void)setupView { 36 | self.view.backgroundColor = [UIColor whiteColor]; 37 | [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:PAGECONTROLLER_STYLE_IDENTIFIER]; 38 | [self.tableView reloadData]; 39 | } 40 | 41 | 42 | #pragma mark - Table view data source 43 | 44 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 45 | return self.datas.count; 46 | } 47 | 48 | 49 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 50 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:PAGECONTROLLER_STYLE_IDENTIFIER forIndexPath:indexPath]; 51 | cell.textLabel.text = [self.datas[indexPath.row] objectForKey:@"name"]; 52 | return cell; 53 | } 54 | 55 | #pragma mark - UITableViewDelegate 56 | 57 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 58 | [tableView deselectRowAtIndexPath:indexPath animated:YES]; 59 | PageControllerViewController *vc = [[PageControllerViewController alloc] init]; 60 | vc.menuLocationStyle = [[self.datas[indexPath.row] objectForKey:@"style"] integerValue]; 61 | [self.navigationController pushViewController:vc animated:YES]; 62 | } 63 | 64 | - (void)didReceiveMemoryWarning { 65 | [super didReceiveMemoryWarning]; 66 | // Dispose of any resources that can be recreated. 67 | } 68 | 69 | @end 70 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemo/ViewController/PageControllerViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // PageControllerViewController.h 3 | // JHPageMenuViewDemo 4 | // 5 | // Created by 谭高丰 on 2017/9/26. 6 | // Copyright © 2017年 谭高丰. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "JHPageController.h" 11 | 12 | @interface PageControllerViewController : UIViewController 13 | 14 | @property (nonatomic, assign) JHPageMenuLocationStyle menuLocationStyle; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemo/ViewController/PageControllerViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // PageControllerViewController.m 3 | // JHPageMenuViewDemo 4 | // 5 | // Created by 谭高丰 on 2017/9/26. 6 | // Copyright © 2017年 谭高丰. All rights reserved. 7 | // 8 | 9 | #import "PageControllerViewController.h" 10 | 11 | @interface PageControllerViewController () 12 | @property (nonatomic, strong) NSMutableArray *childControllers; 13 | @property (nonatomic, strong) NSMutableArray *menus; 14 | @property (nonatomic, strong) JHPageController *pageController; 15 | @end 16 | 17 | @implementation PageControllerViewController 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | self.title = @"JHPageController"; 22 | [self setupData]; 23 | [self setupView]; 24 | } 25 | 26 | - (void)setupData { 27 | self.menus = [NSMutableArray array]; 28 | for (int i = 0; i < 1000; i ++) { 29 | [self.menus addObject:[NSString stringWithFormat:@"标题%i",i + 1]]; 30 | } 31 | self.childControllers = [NSMutableArray array]; 32 | for (int i = 0; i < 1000; i ++) { 33 | UIViewController *childVc = [[UIViewController alloc] init]; 34 | childVc.view.backgroundColor = [UIColor colorWithRed:arc4random_uniform(256)/255.0 green:arc4random_uniform(256)/255.0 blue:arc4random_uniform(256)/255.0 alpha:arc4random_uniform(256)/255.0]; 35 | [self.childControllers addObject:childVc]; 36 | } 37 | } 38 | 39 | - (void)setupView { 40 | UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"切换下标" style:UIBarButtonItemStylePlain target:self action:@selector(switchIndex)]; 41 | self.navigationItem.rightBarButtonItem = item; 42 | self.view.backgroundColor = [UIColor whiteColor]; 43 | [self.view addSubview:self.pageController.view]; 44 | [self.pageController.view mas_makeConstraints:^(MASConstraintMaker *make) { 45 | make.top.trailing.leading.bottom.equalTo(self.view); 46 | }]; 47 | } 48 | 49 | - (void)didReceiveMemoryWarning { 50 | [super didReceiveMemoryWarning]; 51 | } 52 | 53 | #pragma mark - getter 54 | 55 | - (JHPageController *)pageController { 56 | if (!_pageController) { 57 | _pageController = [[JHPageController alloc] initWithMenuLocationStyle:self.menuLocationStyle navBarController:self]; 58 | _pageController.menuItemSize = self.menuLocationStyle == JHPageMenuLocationStyleNavBar ? CGSizeMake(80, 30) : CGSizeMake(80, 50); 59 | _pageController.delegate = self; 60 | _pageController.dataSource = self; 61 | if (self.menuLocationStyle == JHPageMenuLocationStyleNavBar) { 62 | _pageController.decorateStyle = JHPageDecorateStyleFlood; 63 | // 设置菜单视图本身的样式 64 | _pageController.menuBackgroundColor = [UIColor whiteColor]; 65 | _pageController.menuSize = CGSizeMake(160, 30); 66 | _pageController.menuCornerRadius = 15.0; 67 | _pageController.menuBorderWidth = 1.0; 68 | _pageController.menuBorderColor = [UIColor redColor]; 69 | } else { 70 | _pageController.decorateStyle = JHPageDecorateStyleLine; 71 | _pageController.decorateSize = (self.menuLocationStyle == JHPageMenuLocationStyleTop || self.menuLocationStyle == JHPageMenuLocationStyleBottom || self.menuLocationStyle == JHPageMenuLocationStyleNavBar ) ? CGSizeMake(40, 2) : CGSizeMake(2, 40); 72 | _pageController.selectIndex = 5; 73 | } 74 | } 75 | return _pageController; 76 | } 77 | 78 | #pragma mark - JHPageControllerDataSource 79 | 80 | - (NSInteger)numbersOfViewControllerInPageController:(JHPageController *)pageController { 81 | return self.menuLocationStyle == JHPageMenuLocationStyleNavBar ? 2 : self.childControllers.count; 82 | } 83 | 84 | - (NSInteger)indexOfViewController:(UIViewController *)viewController { 85 | return [self.childControllers indexOfObject:viewController]; 86 | } 87 | 88 | - (UIViewController *)pageController:(JHPageController *)pageController viewContrlllerAtIndex:(NSInteger)index { 89 | return [self.childControllers objectAtIndex:index]; 90 | } 91 | 92 | - (JHPageMenuItem *)pageController:(JHPageController *)pageController menuView:(JHPageMenuView *)menuView menuItemAtIndex:(NSInteger)index { 93 | JHPageMenuItem *item = [JHPageMenuItem menuView:menuView itemForIndex:index]; 94 | item.titleLabel.text = self.menus[index]; 95 | __weak typeof(item)weakItem = item; 96 | __weak typeof(self)weakSelf = self; 97 | // 样式 98 | item.menuItemNormalStyleBlock = ^{ 99 | if (weakSelf.menuLocationStyle == JHPageMenuLocationStyleNavBar) { 100 | weakItem.titleLabel.textColor = [UIColor redColor]; 101 | } else { 102 | weakItem.titleLabel.textColor = [UIColor grayColor]; 103 | } 104 | }; 105 | item.menuItemSelectedStyleBlock = ^{ 106 | if (weakSelf.menuLocationStyle == JHPageMenuLocationStyleNavBar) { 107 | weakItem.titleLabel.textColor = [UIColor whiteColor]; 108 | } else { 109 | weakItem.titleLabel.textColor = [UIColor redColor]; 110 | } 111 | }; 112 | return item; 113 | } 114 | 115 | #pragma mark - JHPageControllerDelegate 116 | 117 | - (void)pageController:(JHPageController *)pageController willEnterViewControllerAtIndex:(NSInteger)index { 118 | NSLog(@"将要进入第 %ld 个控制器",index + 1); 119 | } 120 | 121 | - (void)pageController:(JHPageController *)pageController didEnterViewControllerAtIndex:(NSInteger)index { 122 | NSLog(@"已经进入第 %ld 个控制器",index + 1); 123 | } 124 | 125 | #pragma mark - action 126 | 127 | - (void)switchIndex { 128 | self.pageController.selectIndex = 1; 129 | } 130 | 131 | @end 132 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // JHPageMenuViewDemo 4 | // 5 | // Created by 谭高丰 on 2017/9/21. 6 | // Copyright © 2017年 谭高丰. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemoTests/JHPageMenuViewDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // JHPageMenuViewDemoTests.m 3 | // JHPageMenuViewDemoTests 4 | // 5 | // Created by 谭高丰 on 2017/9/21. 6 | // Copyright © 2017年 谭高丰. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface JHPageMenuViewDemoTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation JHPageMenuViewDemoTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemoUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/JHPageMenuViewDemoUITests/JHPageMenuViewDemoUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // JHPageMenuViewDemoUITests.m 3 | // JHPageMenuViewDemoUITests 4 | // 5 | // Created by 谭高丰 on 2017/9/21. 6 | // Copyright © 2017年 谭高丰. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface JHPageMenuViewDemoUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation JHPageMenuViewDemoUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Podfile: -------------------------------------------------------------------------------- 1 | platform :ios, ‘9.0’ 2 | 3 | target 'JHPageMenuViewDemo' do 4 | pod 'Masonry', '~> 1.0.2' 5 | end 6 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Masonry (1.0.2) 3 | 4 | DEPENDENCIES: 5 | - Masonry (~> 1.0.2) 6 | 7 | SPEC CHECKSUMS: 8 | Masonry: 7c429b56da9d4ee0bbb3ed77a5ea710d6a5df39e 9 | 10 | PODFILE CHECKSUM: b5b23830ffe54274c8416857e5f53a24da03ac76 11 | 12 | COCOAPODS: 1.3.1 13 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Headers/Private/Masonry/MASCompositeConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASCompositeConstraint.h -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Headers/Private/Masonry/MASConstraint+Private.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASConstraint+Private.h -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Headers/Private/Masonry/MASConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASConstraint.h -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Headers/Private/Masonry/MASConstraintMaker.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASConstraintMaker.h -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Headers/Private/Masonry/MASLayoutConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASLayoutConstraint.h -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Headers/Private/Masonry/MASUtilities.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASUtilities.h -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Headers/Private/Masonry/MASViewAttribute.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASViewAttribute.h -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Headers/Private/Masonry/MASViewConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASViewConstraint.h -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Headers/Private/Masonry/Masonry.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/Masonry.h -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Headers/Private/Masonry/NSArray+MASAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/NSArray+MASAdditions.h -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Headers/Private/Masonry/NSArray+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/NSArray+MASShorthandAdditions.h -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Headers/Private/Masonry/NSLayoutConstraint+MASDebugAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/NSLayoutConstraint+MASDebugAdditions.h -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Headers/Private/Masonry/View+MASAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/View+MASAdditions.h -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Headers/Private/Masonry/View+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/View+MASShorthandAdditions.h -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Headers/Private/Masonry/ViewController+MASAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/ViewController+MASAdditions.h -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Headers/Public/Masonry/MASCompositeConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASCompositeConstraint.h -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Headers/Public/Masonry/MASConstraint+Private.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASConstraint+Private.h -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Headers/Public/Masonry/MASConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASConstraint.h -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Headers/Public/Masonry/MASConstraintMaker.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASConstraintMaker.h -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Headers/Public/Masonry/MASLayoutConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASLayoutConstraint.h -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Headers/Public/Masonry/MASUtilities.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASUtilities.h -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Headers/Public/Masonry/MASViewAttribute.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASViewAttribute.h -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Headers/Public/Masonry/MASViewConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASViewConstraint.h -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Headers/Public/Masonry/Masonry.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/Masonry.h -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Headers/Public/Masonry/NSArray+MASAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/NSArray+MASAdditions.h -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Headers/Public/Masonry/NSArray+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/NSArray+MASShorthandAdditions.h -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Headers/Public/Masonry/NSLayoutConstraint+MASDebugAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/NSLayoutConstraint+MASDebugAdditions.h -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Headers/Public/Masonry/View+MASAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/View+MASAdditions.h -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Headers/Public/Masonry/View+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/View+MASShorthandAdditions.h -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Headers/Public/Masonry/ViewController+MASAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/ViewController+MASAdditions.h -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Masonry (1.0.2) 3 | 4 | DEPENDENCIES: 5 | - Masonry (~> 1.0.2) 6 | 7 | SPEC CHECKSUMS: 8 | Masonry: 7c429b56da9d4ee0bbb3ed77a5ea710d6a5df39e 9 | 10 | PODFILE CHECKSUM: b5b23830ffe54274c8416857e5f53a24da03ac76 11 | 12 | COCOAPODS: 1.3.1 13 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Masonry/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2012 Masonry Team - https://github.com/Masonry 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Masonry/Masonry/MASCompositeConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASCompositeConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraint.h" 10 | #import "MASUtilities.h" 11 | 12 | /** 13 | * A group of MASConstraint objects 14 | */ 15 | @interface MASCompositeConstraint : MASConstraint 16 | 17 | /** 18 | * Creates a composite with a predefined array of children 19 | * 20 | * @param children child MASConstraints 21 | * 22 | * @return a composite constraint 23 | */ 24 | - (id)initWithChildren:(NSArray *)children; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Masonry/Masonry/MASCompositeConstraint.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASCompositeConstraint.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASCompositeConstraint.h" 10 | #import "MASConstraint+Private.h" 11 | 12 | @interface MASCompositeConstraint () 13 | 14 | @property (nonatomic, strong) id mas_key; 15 | @property (nonatomic, strong) NSMutableArray *childConstraints; 16 | 17 | @end 18 | 19 | @implementation MASCompositeConstraint 20 | 21 | - (id)initWithChildren:(NSArray *)children { 22 | self = [super init]; 23 | if (!self) return nil; 24 | 25 | _childConstraints = [children mutableCopy]; 26 | for (MASConstraint *constraint in _childConstraints) { 27 | constraint.delegate = self; 28 | } 29 | 30 | return self; 31 | } 32 | 33 | #pragma mark - MASConstraintDelegate 34 | 35 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint { 36 | NSUInteger index = [self.childConstraints indexOfObject:constraint]; 37 | NSAssert(index != NSNotFound, @"Could not find constraint %@", constraint); 38 | [self.childConstraints replaceObjectAtIndex:index withObject:replacementConstraint]; 39 | } 40 | 41 | - (MASConstraint *)constraint:(MASConstraint __unused *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 42 | id strongDelegate = self.delegate; 43 | MASConstraint *newConstraint = [strongDelegate constraint:self addConstraintWithLayoutAttribute:layoutAttribute]; 44 | newConstraint.delegate = self; 45 | [self.childConstraints addObject:newConstraint]; 46 | return newConstraint; 47 | } 48 | 49 | #pragma mark - NSLayoutConstraint multiplier proxies 50 | 51 | - (MASConstraint * (^)(CGFloat))multipliedBy { 52 | return ^id(CGFloat multiplier) { 53 | for (MASConstraint *constraint in self.childConstraints) { 54 | constraint.multipliedBy(multiplier); 55 | } 56 | return self; 57 | }; 58 | } 59 | 60 | - (MASConstraint * (^)(CGFloat))dividedBy { 61 | return ^id(CGFloat divider) { 62 | for (MASConstraint *constraint in self.childConstraints) { 63 | constraint.dividedBy(divider); 64 | } 65 | return self; 66 | }; 67 | } 68 | 69 | #pragma mark - MASLayoutPriority proxy 70 | 71 | - (MASConstraint * (^)(MASLayoutPriority))priority { 72 | return ^id(MASLayoutPriority priority) { 73 | for (MASConstraint *constraint in self.childConstraints) { 74 | constraint.priority(priority); 75 | } 76 | return self; 77 | }; 78 | } 79 | 80 | #pragma mark - NSLayoutRelation proxy 81 | 82 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { 83 | return ^id(id attr, NSLayoutRelation relation) { 84 | for (MASConstraint *constraint in self.childConstraints.copy) { 85 | constraint.equalToWithRelation(attr, relation); 86 | } 87 | return self; 88 | }; 89 | } 90 | 91 | #pragma mark - attribute chaining 92 | 93 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 94 | [self constraint:self addConstraintWithLayoutAttribute:layoutAttribute]; 95 | return self; 96 | } 97 | 98 | #pragma mark - Animator proxy 99 | 100 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV) 101 | 102 | - (MASConstraint *)animator { 103 | for (MASConstraint *constraint in self.childConstraints) { 104 | [constraint animator]; 105 | } 106 | return self; 107 | } 108 | 109 | #endif 110 | 111 | #pragma mark - debug helpers 112 | 113 | - (MASConstraint * (^)(id))key { 114 | return ^id(id key) { 115 | self.mas_key = key; 116 | int i = 0; 117 | for (MASConstraint *constraint in self.childConstraints) { 118 | constraint.key([NSString stringWithFormat:@"%@[%d]", key, i++]); 119 | } 120 | return self; 121 | }; 122 | } 123 | 124 | #pragma mark - NSLayoutConstraint constant setters 125 | 126 | - (void)setInsets:(MASEdgeInsets)insets { 127 | for (MASConstraint *constraint in self.childConstraints) { 128 | constraint.insets = insets; 129 | } 130 | } 131 | 132 | - (void)setOffset:(CGFloat)offset { 133 | for (MASConstraint *constraint in self.childConstraints) { 134 | constraint.offset = offset; 135 | } 136 | } 137 | 138 | - (void)setSizeOffset:(CGSize)sizeOffset { 139 | for (MASConstraint *constraint in self.childConstraints) { 140 | constraint.sizeOffset = sizeOffset; 141 | } 142 | } 143 | 144 | - (void)setCenterOffset:(CGPoint)centerOffset { 145 | for (MASConstraint *constraint in self.childConstraints) { 146 | constraint.centerOffset = centerOffset; 147 | } 148 | } 149 | 150 | #pragma mark - MASConstraint 151 | 152 | - (void)activate { 153 | for (MASConstraint *constraint in self.childConstraints) { 154 | [constraint activate]; 155 | } 156 | } 157 | 158 | - (void)deactivate { 159 | for (MASConstraint *constraint in self.childConstraints) { 160 | [constraint deactivate]; 161 | } 162 | } 163 | 164 | - (void)install { 165 | for (MASConstraint *constraint in self.childConstraints) { 166 | constraint.updateExisting = self.updateExisting; 167 | [constraint install]; 168 | } 169 | } 170 | 171 | - (void)uninstall { 172 | for (MASConstraint *constraint in self.childConstraints) { 173 | [constraint uninstall]; 174 | } 175 | } 176 | 177 | @end 178 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Masonry/Masonry/MASConstraint+Private.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint+Private.h 3 | // Masonry 4 | // 5 | // Created by Nick Tymchenko on 29/04/14. 6 | // Copyright (c) 2014 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraint.h" 10 | 11 | @protocol MASConstraintDelegate; 12 | 13 | 14 | @interface MASConstraint () 15 | 16 | /** 17 | * Whether or not to check for an existing constraint instead of adding constraint 18 | */ 19 | @property (nonatomic, assign) BOOL updateExisting; 20 | 21 | /** 22 | * Usually MASConstraintMaker but could be a parent MASConstraint 23 | */ 24 | @property (nonatomic, weak) id delegate; 25 | 26 | /** 27 | * Based on a provided value type, is equal to calling: 28 | * NSNumber - setOffset: 29 | * NSValue with CGPoint - setPointOffset: 30 | * NSValue with CGSize - setSizeOffset: 31 | * NSValue with MASEdgeInsets - setInsets: 32 | */ 33 | - (void)setLayoutConstantWithValue:(NSValue *)value; 34 | 35 | @end 36 | 37 | 38 | @interface MASConstraint (Abstract) 39 | 40 | /** 41 | * Sets the constraint relation to given NSLayoutRelation 42 | * returns a block which accepts one of the following: 43 | * MASViewAttribute, UIView, NSValue, NSArray 44 | * see readme for more details. 45 | */ 46 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation; 47 | 48 | /** 49 | * Override to set a custom chaining behaviour 50 | */ 51 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute; 52 | 53 | @end 54 | 55 | 56 | @protocol MASConstraintDelegate 57 | 58 | /** 59 | * Notifies the delegate when the constraint needs to be replaced with another constraint. For example 60 | * A MASViewConstraint may turn into a MASCompositeConstraint when an array is passed to one of the equality blocks 61 | */ 62 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint; 63 | 64 | - (MASConstraint *)constraint:(MASConstraint *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute; 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Masonry/Masonry/MASConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 22/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * Enables Constraints to be created with chainable syntax 13 | * Constraint can represent single NSLayoutConstraint (MASViewConstraint) 14 | * or a group of NSLayoutConstraints (MASComposisteConstraint) 15 | */ 16 | @interface MASConstraint : NSObject 17 | 18 | // Chaining Support 19 | 20 | /** 21 | * Modifies the NSLayoutConstraint constant, 22 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 23 | * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight 24 | */ 25 | - (MASConstraint * (^)(MASEdgeInsets insets))insets; 26 | 27 | /** 28 | * Modifies the NSLayoutConstraint constant, 29 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 30 | * NSLayoutAttributeWidth, NSLayoutAttributeHeight 31 | */ 32 | - (MASConstraint * (^)(CGSize offset))sizeOffset; 33 | 34 | /** 35 | * Modifies the NSLayoutConstraint constant, 36 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 37 | * NSLayoutAttributeCenterX, NSLayoutAttributeCenterY 38 | */ 39 | - (MASConstraint * (^)(CGPoint offset))centerOffset; 40 | 41 | /** 42 | * Modifies the NSLayoutConstraint constant 43 | */ 44 | - (MASConstraint * (^)(CGFloat offset))offset; 45 | 46 | /** 47 | * Modifies the NSLayoutConstraint constant based on a value type 48 | */ 49 | - (MASConstraint * (^)(NSValue *value))valueOffset; 50 | 51 | /** 52 | * Sets the NSLayoutConstraint multiplier property 53 | */ 54 | - (MASConstraint * (^)(CGFloat multiplier))multipliedBy; 55 | 56 | /** 57 | * Sets the NSLayoutConstraint multiplier to 1.0/dividedBy 58 | */ 59 | - (MASConstraint * (^)(CGFloat divider))dividedBy; 60 | 61 | /** 62 | * Sets the NSLayoutConstraint priority to a float or MASLayoutPriority 63 | */ 64 | - (MASConstraint * (^)(MASLayoutPriority priority))priority; 65 | 66 | /** 67 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityLow 68 | */ 69 | - (MASConstraint * (^)())priorityLow; 70 | 71 | /** 72 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityMedium 73 | */ 74 | - (MASConstraint * (^)())priorityMedium; 75 | 76 | /** 77 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityHigh 78 | */ 79 | - (MASConstraint * (^)())priorityHigh; 80 | 81 | /** 82 | * Sets the constraint relation to NSLayoutRelationEqual 83 | * returns a block which accepts one of the following: 84 | * MASViewAttribute, UIView, NSValue, NSArray 85 | * see readme for more details. 86 | */ 87 | - (MASConstraint * (^)(id attr))equalTo; 88 | 89 | /** 90 | * Sets the constraint relation to NSLayoutRelationGreaterThanOrEqual 91 | * returns a block which accepts one of the following: 92 | * MASViewAttribute, UIView, NSValue, NSArray 93 | * see readme for more details. 94 | */ 95 | - (MASConstraint * (^)(id attr))greaterThanOrEqualTo; 96 | 97 | /** 98 | * Sets the constraint relation to NSLayoutRelationLessThanOrEqual 99 | * returns a block which accepts one of the following: 100 | * MASViewAttribute, UIView, NSValue, NSArray 101 | * see readme for more details. 102 | */ 103 | - (MASConstraint * (^)(id attr))lessThanOrEqualTo; 104 | 105 | /** 106 | * Optional semantic property which has no effect but improves the readability of constraint 107 | */ 108 | - (MASConstraint *)with; 109 | 110 | /** 111 | * Optional semantic property which has no effect but improves the readability of constraint 112 | */ 113 | - (MASConstraint *)and; 114 | 115 | /** 116 | * Creates a new MASCompositeConstraint with the called attribute and reciever 117 | */ 118 | - (MASConstraint *)left; 119 | - (MASConstraint *)top; 120 | - (MASConstraint *)right; 121 | - (MASConstraint *)bottom; 122 | - (MASConstraint *)leading; 123 | - (MASConstraint *)trailing; 124 | - (MASConstraint *)width; 125 | - (MASConstraint *)height; 126 | - (MASConstraint *)centerX; 127 | - (MASConstraint *)centerY; 128 | - (MASConstraint *)baseline; 129 | 130 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 131 | 132 | - (MASConstraint *)firstBaseline; 133 | - (MASConstraint *)lastBaseline; 134 | 135 | #endif 136 | 137 | #if TARGET_OS_IPHONE || TARGET_OS_TV 138 | 139 | - (MASConstraint *)leftMargin; 140 | - (MASConstraint *)rightMargin; 141 | - (MASConstraint *)topMargin; 142 | - (MASConstraint *)bottomMargin; 143 | - (MASConstraint *)leadingMargin; 144 | - (MASConstraint *)trailingMargin; 145 | - (MASConstraint *)centerXWithinMargins; 146 | - (MASConstraint *)centerYWithinMargins; 147 | 148 | #endif 149 | 150 | 151 | /** 152 | * Sets the constraint debug name 153 | */ 154 | - (MASConstraint * (^)(id key))key; 155 | 156 | // NSLayoutConstraint constant Setters 157 | // for use outside of mas_updateConstraints/mas_makeConstraints blocks 158 | 159 | /** 160 | * Modifies the NSLayoutConstraint constant, 161 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 162 | * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight 163 | */ 164 | - (void)setInsets:(MASEdgeInsets)insets; 165 | 166 | /** 167 | * Modifies the NSLayoutConstraint constant, 168 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 169 | * NSLayoutAttributeWidth, NSLayoutAttributeHeight 170 | */ 171 | - (void)setSizeOffset:(CGSize)sizeOffset; 172 | 173 | /** 174 | * Modifies the NSLayoutConstraint constant, 175 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 176 | * NSLayoutAttributeCenterX, NSLayoutAttributeCenterY 177 | */ 178 | - (void)setCenterOffset:(CGPoint)centerOffset; 179 | 180 | /** 181 | * Modifies the NSLayoutConstraint constant 182 | */ 183 | - (void)setOffset:(CGFloat)offset; 184 | 185 | 186 | // NSLayoutConstraint Installation support 187 | 188 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV) 189 | /** 190 | * Whether or not to go through the animator proxy when modifying the constraint 191 | */ 192 | @property (nonatomic, copy, readonly) MASConstraint *animator; 193 | #endif 194 | 195 | /** 196 | * Activates an NSLayoutConstraint if it's supported by an OS. 197 | * Invokes install otherwise. 198 | */ 199 | - (void)activate; 200 | 201 | /** 202 | * Deactivates previously installed/activated NSLayoutConstraint. 203 | */ 204 | - (void)deactivate; 205 | 206 | /** 207 | * Creates a NSLayoutConstraint and adds it to the appropriate view. 208 | */ 209 | - (void)install; 210 | 211 | /** 212 | * Removes previously installed NSLayoutConstraint 213 | */ 214 | - (void)uninstall; 215 | 216 | @end 217 | 218 | 219 | /** 220 | * Convenience auto-boxing macros for MASConstraint methods. 221 | * 222 | * Defining MAS_SHORTHAND_GLOBALS will turn on auto-boxing for default syntax. 223 | * A potential drawback of this is that the unprefixed macros will appear in global scope. 224 | */ 225 | #define mas_equalTo(...) equalTo(MASBoxValue((__VA_ARGS__))) 226 | #define mas_greaterThanOrEqualTo(...) greaterThanOrEqualTo(MASBoxValue((__VA_ARGS__))) 227 | #define mas_lessThanOrEqualTo(...) lessThanOrEqualTo(MASBoxValue((__VA_ARGS__))) 228 | 229 | #define mas_offset(...) valueOffset(MASBoxValue((__VA_ARGS__))) 230 | 231 | 232 | #ifdef MAS_SHORTHAND_GLOBALS 233 | 234 | #define equalTo(...) mas_equalTo(__VA_ARGS__) 235 | #define greaterThanOrEqualTo(...) mas_greaterThanOrEqualTo(__VA_ARGS__) 236 | #define lessThanOrEqualTo(...) mas_lessThanOrEqualTo(__VA_ARGS__) 237 | 238 | #define offset(...) mas_offset(__VA_ARGS__) 239 | 240 | #endif 241 | 242 | 243 | @interface MASConstraint (AutoboxingSupport) 244 | 245 | /** 246 | * Aliases to corresponding relation methods (for shorthand macros) 247 | * Also needed to aid autocompletion 248 | */ 249 | - (MASConstraint * (^)(id attr))mas_equalTo; 250 | - (MASConstraint * (^)(id attr))mas_greaterThanOrEqualTo; 251 | - (MASConstraint * (^)(id attr))mas_lessThanOrEqualTo; 252 | 253 | /** 254 | * A dummy method to aid autocompletion 255 | */ 256 | - (MASConstraint * (^)(id offset))mas_offset; 257 | 258 | @end 259 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Masonry/Masonry/MASConstraint.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint.m 3 | // Masonry 4 | // 5 | // Created by Nick Tymchenko on 1/20/14. 6 | // 7 | 8 | #import "MASConstraint.h" 9 | #import "MASConstraint+Private.h" 10 | 11 | #define MASMethodNotImplemented() \ 12 | @throw [NSException exceptionWithName:NSInternalInconsistencyException \ 13 | reason:[NSString stringWithFormat:@"You must override %@ in a subclass.", NSStringFromSelector(_cmd)] \ 14 | userInfo:nil] 15 | 16 | @implementation MASConstraint 17 | 18 | #pragma mark - Init 19 | 20 | - (id)init { 21 | NSAssert(![self isMemberOfClass:[MASConstraint class]], @"MASConstraint is an abstract class, you should not instantiate it directly."); 22 | return [super init]; 23 | } 24 | 25 | #pragma mark - NSLayoutRelation proxies 26 | 27 | - (MASConstraint * (^)(id))equalTo { 28 | return ^id(id attribute) { 29 | return self.equalToWithRelation(attribute, NSLayoutRelationEqual); 30 | }; 31 | } 32 | 33 | - (MASConstraint * (^)(id))mas_equalTo { 34 | return ^id(id attribute) { 35 | return self.equalToWithRelation(attribute, NSLayoutRelationEqual); 36 | }; 37 | } 38 | 39 | - (MASConstraint * (^)(id))greaterThanOrEqualTo { 40 | return ^id(id attribute) { 41 | return self.equalToWithRelation(attribute, NSLayoutRelationGreaterThanOrEqual); 42 | }; 43 | } 44 | 45 | - (MASConstraint * (^)(id))mas_greaterThanOrEqualTo { 46 | return ^id(id attribute) { 47 | return self.equalToWithRelation(attribute, NSLayoutRelationGreaterThanOrEqual); 48 | }; 49 | } 50 | 51 | - (MASConstraint * (^)(id))lessThanOrEqualTo { 52 | return ^id(id attribute) { 53 | return self.equalToWithRelation(attribute, NSLayoutRelationLessThanOrEqual); 54 | }; 55 | } 56 | 57 | - (MASConstraint * (^)(id))mas_lessThanOrEqualTo { 58 | return ^id(id attribute) { 59 | return self.equalToWithRelation(attribute, NSLayoutRelationLessThanOrEqual); 60 | }; 61 | } 62 | 63 | #pragma mark - MASLayoutPriority proxies 64 | 65 | - (MASConstraint * (^)())priorityLow { 66 | return ^id{ 67 | self.priority(MASLayoutPriorityDefaultLow); 68 | return self; 69 | }; 70 | } 71 | 72 | - (MASConstraint * (^)())priorityMedium { 73 | return ^id{ 74 | self.priority(MASLayoutPriorityDefaultMedium); 75 | return self; 76 | }; 77 | } 78 | 79 | - (MASConstraint * (^)())priorityHigh { 80 | return ^id{ 81 | self.priority(MASLayoutPriorityDefaultHigh); 82 | return self; 83 | }; 84 | } 85 | 86 | #pragma mark - NSLayoutConstraint constant proxies 87 | 88 | - (MASConstraint * (^)(MASEdgeInsets))insets { 89 | return ^id(MASEdgeInsets insets){ 90 | self.insets = insets; 91 | return self; 92 | }; 93 | } 94 | 95 | - (MASConstraint * (^)(CGSize))sizeOffset { 96 | return ^id(CGSize offset) { 97 | self.sizeOffset = offset; 98 | return self; 99 | }; 100 | } 101 | 102 | - (MASConstraint * (^)(CGPoint))centerOffset { 103 | return ^id(CGPoint offset) { 104 | self.centerOffset = offset; 105 | return self; 106 | }; 107 | } 108 | 109 | - (MASConstraint * (^)(CGFloat))offset { 110 | return ^id(CGFloat offset){ 111 | self.offset = offset; 112 | return self; 113 | }; 114 | } 115 | 116 | - (MASConstraint * (^)(NSValue *value))valueOffset { 117 | return ^id(NSValue *offset) { 118 | NSAssert([offset isKindOfClass:NSValue.class], @"expected an NSValue offset, got: %@", offset); 119 | [self setLayoutConstantWithValue:offset]; 120 | return self; 121 | }; 122 | } 123 | 124 | - (MASConstraint * (^)(id offset))mas_offset { 125 | // Will never be called due to macro 126 | return nil; 127 | } 128 | 129 | #pragma mark - NSLayoutConstraint constant setter 130 | 131 | - (void)setLayoutConstantWithValue:(NSValue *)value { 132 | if ([value isKindOfClass:NSNumber.class]) { 133 | self.offset = [(NSNumber *)value doubleValue]; 134 | } else if (strcmp(value.objCType, @encode(CGPoint)) == 0) { 135 | CGPoint point; 136 | [value getValue:&point]; 137 | self.centerOffset = point; 138 | } else if (strcmp(value.objCType, @encode(CGSize)) == 0) { 139 | CGSize size; 140 | [value getValue:&size]; 141 | self.sizeOffset = size; 142 | } else if (strcmp(value.objCType, @encode(MASEdgeInsets)) == 0) { 143 | MASEdgeInsets insets; 144 | [value getValue:&insets]; 145 | self.insets = insets; 146 | } else { 147 | NSAssert(NO, @"attempting to set layout constant with unsupported value: %@", value); 148 | } 149 | } 150 | 151 | #pragma mark - Semantic properties 152 | 153 | - (MASConstraint *)with { 154 | return self; 155 | } 156 | 157 | - (MASConstraint *)and { 158 | return self; 159 | } 160 | 161 | #pragma mark - Chaining 162 | 163 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute __unused)layoutAttribute { 164 | MASMethodNotImplemented(); 165 | } 166 | 167 | - (MASConstraint *)left { 168 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeft]; 169 | } 170 | 171 | - (MASConstraint *)top { 172 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTop]; 173 | } 174 | 175 | - (MASConstraint *)right { 176 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRight]; 177 | } 178 | 179 | - (MASConstraint *)bottom { 180 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottom]; 181 | } 182 | 183 | - (MASConstraint *)leading { 184 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeading]; 185 | } 186 | 187 | - (MASConstraint *)trailing { 188 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailing]; 189 | } 190 | 191 | - (MASConstraint *)width { 192 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeWidth]; 193 | } 194 | 195 | - (MASConstraint *)height { 196 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeHeight]; 197 | } 198 | 199 | - (MASConstraint *)centerX { 200 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterX]; 201 | } 202 | 203 | - (MASConstraint *)centerY { 204 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterY]; 205 | } 206 | 207 | - (MASConstraint *)baseline { 208 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBaseline]; 209 | } 210 | 211 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 212 | 213 | - (MASConstraint *)firstBaseline { 214 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeFirstBaseline]; 215 | } 216 | - (MASConstraint *)lastBaseline { 217 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLastBaseline]; 218 | } 219 | 220 | #endif 221 | 222 | #if TARGET_OS_IPHONE || TARGET_OS_TV 223 | 224 | - (MASConstraint *)leftMargin { 225 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeftMargin]; 226 | } 227 | 228 | - (MASConstraint *)rightMargin { 229 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRightMargin]; 230 | } 231 | 232 | - (MASConstraint *)topMargin { 233 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTopMargin]; 234 | } 235 | 236 | - (MASConstraint *)bottomMargin { 237 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottomMargin]; 238 | } 239 | 240 | - (MASConstraint *)leadingMargin { 241 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeadingMargin]; 242 | } 243 | 244 | - (MASConstraint *)trailingMargin { 245 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailingMargin]; 246 | } 247 | 248 | - (MASConstraint *)centerXWithinMargins { 249 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterXWithinMargins]; 250 | } 251 | 252 | - (MASConstraint *)centerYWithinMargins { 253 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterYWithinMargins]; 254 | } 255 | 256 | #endif 257 | 258 | #pragma mark - Abstract 259 | 260 | - (MASConstraint * (^)(CGFloat multiplier))multipliedBy { MASMethodNotImplemented(); } 261 | 262 | - (MASConstraint * (^)(CGFloat divider))dividedBy { MASMethodNotImplemented(); } 263 | 264 | - (MASConstraint * (^)(MASLayoutPriority priority))priority { MASMethodNotImplemented(); } 265 | 266 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { MASMethodNotImplemented(); } 267 | 268 | - (MASConstraint * (^)(id key))key { MASMethodNotImplemented(); } 269 | 270 | - (void)setInsets:(MASEdgeInsets __unused)insets { MASMethodNotImplemented(); } 271 | 272 | - (void)setSizeOffset:(CGSize __unused)sizeOffset { MASMethodNotImplemented(); } 273 | 274 | - (void)setCenterOffset:(CGPoint __unused)centerOffset { MASMethodNotImplemented(); } 275 | 276 | - (void)setOffset:(CGFloat __unused)offset { MASMethodNotImplemented(); } 277 | 278 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV) 279 | 280 | - (MASConstraint *)animator { MASMethodNotImplemented(); } 281 | 282 | #endif 283 | 284 | - (void)activate { MASMethodNotImplemented(); } 285 | 286 | - (void)deactivate { MASMethodNotImplemented(); } 287 | 288 | - (void)install { MASMethodNotImplemented(); } 289 | 290 | - (void)uninstall { MASMethodNotImplemented(); } 291 | 292 | @end 293 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Masonry/Masonry/MASConstraintMaker.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraintBuilder.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraint.h" 10 | #import "MASUtilities.h" 11 | 12 | typedef NS_OPTIONS(NSInteger, MASAttribute) { 13 | MASAttributeLeft = 1 << NSLayoutAttributeLeft, 14 | MASAttributeRight = 1 << NSLayoutAttributeRight, 15 | MASAttributeTop = 1 << NSLayoutAttributeTop, 16 | MASAttributeBottom = 1 << NSLayoutAttributeBottom, 17 | MASAttributeLeading = 1 << NSLayoutAttributeLeading, 18 | MASAttributeTrailing = 1 << NSLayoutAttributeTrailing, 19 | MASAttributeWidth = 1 << NSLayoutAttributeWidth, 20 | MASAttributeHeight = 1 << NSLayoutAttributeHeight, 21 | MASAttributeCenterX = 1 << NSLayoutAttributeCenterX, 22 | MASAttributeCenterY = 1 << NSLayoutAttributeCenterY, 23 | MASAttributeBaseline = 1 << NSLayoutAttributeBaseline, 24 | 25 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 26 | 27 | MASAttributeFirstBaseline = 1 << NSLayoutAttributeFirstBaseline, 28 | MASAttributeLastBaseline = 1 << NSLayoutAttributeLastBaseline, 29 | 30 | #endif 31 | 32 | #if TARGET_OS_IPHONE || TARGET_OS_TV 33 | 34 | MASAttributeLeftMargin = 1 << NSLayoutAttributeLeftMargin, 35 | MASAttributeRightMargin = 1 << NSLayoutAttributeRightMargin, 36 | MASAttributeTopMargin = 1 << NSLayoutAttributeTopMargin, 37 | MASAttributeBottomMargin = 1 << NSLayoutAttributeBottomMargin, 38 | MASAttributeLeadingMargin = 1 << NSLayoutAttributeLeadingMargin, 39 | MASAttributeTrailingMargin = 1 << NSLayoutAttributeTrailingMargin, 40 | MASAttributeCenterXWithinMargins = 1 << NSLayoutAttributeCenterXWithinMargins, 41 | MASAttributeCenterYWithinMargins = 1 << NSLayoutAttributeCenterYWithinMargins, 42 | 43 | #endif 44 | 45 | }; 46 | 47 | /** 48 | * Provides factory methods for creating MASConstraints. 49 | * Constraints are collected until they are ready to be installed 50 | * 51 | */ 52 | @interface MASConstraintMaker : NSObject 53 | 54 | /** 55 | * The following properties return a new MASViewConstraint 56 | * with the first item set to the makers associated view and the appropriate MASViewAttribute 57 | */ 58 | @property (nonatomic, strong, readonly) MASConstraint *left; 59 | @property (nonatomic, strong, readonly) MASConstraint *top; 60 | @property (nonatomic, strong, readonly) MASConstraint *right; 61 | @property (nonatomic, strong, readonly) MASConstraint *bottom; 62 | @property (nonatomic, strong, readonly) MASConstraint *leading; 63 | @property (nonatomic, strong, readonly) MASConstraint *trailing; 64 | @property (nonatomic, strong, readonly) MASConstraint *width; 65 | @property (nonatomic, strong, readonly) MASConstraint *height; 66 | @property (nonatomic, strong, readonly) MASConstraint *centerX; 67 | @property (nonatomic, strong, readonly) MASConstraint *centerY; 68 | @property (nonatomic, strong, readonly) MASConstraint *baseline; 69 | 70 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 71 | 72 | @property (nonatomic, strong, readonly) MASConstraint *firstBaseline; 73 | @property (nonatomic, strong, readonly) MASConstraint *lastBaseline; 74 | 75 | #endif 76 | 77 | #if TARGET_OS_IPHONE || TARGET_OS_TV 78 | 79 | @property (nonatomic, strong, readonly) MASConstraint *leftMargin; 80 | @property (nonatomic, strong, readonly) MASConstraint *rightMargin; 81 | @property (nonatomic, strong, readonly) MASConstraint *topMargin; 82 | @property (nonatomic, strong, readonly) MASConstraint *bottomMargin; 83 | @property (nonatomic, strong, readonly) MASConstraint *leadingMargin; 84 | @property (nonatomic, strong, readonly) MASConstraint *trailingMargin; 85 | @property (nonatomic, strong, readonly) MASConstraint *centerXWithinMargins; 86 | @property (nonatomic, strong, readonly) MASConstraint *centerYWithinMargins; 87 | 88 | #endif 89 | 90 | /** 91 | * Returns a block which creates a new MASCompositeConstraint with the first item set 92 | * to the makers associated view and children corresponding to the set bits in the 93 | * MASAttribute parameter. Combine multiple attributes via binary-or. 94 | */ 95 | @property (nonatomic, strong, readonly) MASConstraint *(^attributes)(MASAttribute attrs); 96 | 97 | /** 98 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeEdges 99 | * which generates the appropriate MASViewConstraint children (top, left, bottom, right) 100 | * with the first item set to the makers associated view 101 | */ 102 | @property (nonatomic, strong, readonly) MASConstraint *edges; 103 | 104 | /** 105 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeSize 106 | * which generates the appropriate MASViewConstraint children (width, height) 107 | * with the first item set to the makers associated view 108 | */ 109 | @property (nonatomic, strong, readonly) MASConstraint *size; 110 | 111 | /** 112 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeCenter 113 | * which generates the appropriate MASViewConstraint children (centerX, centerY) 114 | * with the first item set to the makers associated view 115 | */ 116 | @property (nonatomic, strong, readonly) MASConstraint *center; 117 | 118 | /** 119 | * Whether or not to check for an existing constraint instead of adding constraint 120 | */ 121 | @property (nonatomic, assign) BOOL updateExisting; 122 | 123 | /** 124 | * Whether or not to remove existing constraints prior to installing 125 | */ 126 | @property (nonatomic, assign) BOOL removeExisting; 127 | 128 | /** 129 | * initialises the maker with a default view 130 | * 131 | * @param view any MASConstrait are created with this view as the first item 132 | * 133 | * @return a new MASConstraintMaker 134 | */ 135 | - (id)initWithView:(MAS_VIEW *)view; 136 | 137 | /** 138 | * Calls install method on any MASConstraints which have been created by this maker 139 | * 140 | * @return an array of all the installed MASConstraints 141 | */ 142 | - (NSArray *)install; 143 | 144 | - (MASConstraint * (^)(dispatch_block_t))group; 145 | 146 | @end 147 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Masonry/Masonry/MASConstraintMaker.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraintBuilder.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraintMaker.h" 10 | #import "MASViewConstraint.h" 11 | #import "MASCompositeConstraint.h" 12 | #import "MASConstraint+Private.h" 13 | #import "MASViewAttribute.h" 14 | #import "View+MASAdditions.h" 15 | 16 | @interface MASConstraintMaker () 17 | 18 | @property (nonatomic, weak) MAS_VIEW *view; 19 | @property (nonatomic, strong) NSMutableArray *constraints; 20 | 21 | @end 22 | 23 | @implementation MASConstraintMaker 24 | 25 | - (id)initWithView:(MAS_VIEW *)view { 26 | self = [super init]; 27 | if (!self) return nil; 28 | 29 | self.view = view; 30 | self.constraints = NSMutableArray.new; 31 | 32 | return self; 33 | } 34 | 35 | - (NSArray *)install { 36 | if (self.removeExisting) { 37 | NSArray *installedConstraints = [MASViewConstraint installedConstraintsForView:self.view]; 38 | for (MASConstraint *constraint in installedConstraints) { 39 | [constraint uninstall]; 40 | } 41 | } 42 | NSArray *constraints = self.constraints.copy; 43 | for (MASConstraint *constraint in constraints) { 44 | constraint.updateExisting = self.updateExisting; 45 | [constraint install]; 46 | } 47 | [self.constraints removeAllObjects]; 48 | return constraints; 49 | } 50 | 51 | #pragma mark - MASConstraintDelegate 52 | 53 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint { 54 | NSUInteger index = [self.constraints indexOfObject:constraint]; 55 | NSAssert(index != NSNotFound, @"Could not find constraint %@", constraint); 56 | [self.constraints replaceObjectAtIndex:index withObject:replacementConstraint]; 57 | } 58 | 59 | - (MASConstraint *)constraint:(MASConstraint *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 60 | MASViewAttribute *viewAttribute = [[MASViewAttribute alloc] initWithView:self.view layoutAttribute:layoutAttribute]; 61 | MASViewConstraint *newConstraint = [[MASViewConstraint alloc] initWithFirstViewAttribute:viewAttribute]; 62 | if ([constraint isKindOfClass:MASViewConstraint.class]) { 63 | //replace with composite constraint 64 | NSArray *children = @[constraint, newConstraint]; 65 | MASCompositeConstraint *compositeConstraint = [[MASCompositeConstraint alloc] initWithChildren:children]; 66 | compositeConstraint.delegate = self; 67 | [self constraint:constraint shouldBeReplacedWithConstraint:compositeConstraint]; 68 | return compositeConstraint; 69 | } 70 | if (!constraint) { 71 | newConstraint.delegate = self; 72 | [self.constraints addObject:newConstraint]; 73 | } 74 | return newConstraint; 75 | } 76 | 77 | - (MASConstraint *)addConstraintWithAttributes:(MASAttribute)attrs { 78 | __unused MASAttribute anyAttribute = (MASAttributeLeft | MASAttributeRight | MASAttributeTop | MASAttributeBottom | MASAttributeLeading 79 | | MASAttributeTrailing | MASAttributeWidth | MASAttributeHeight | MASAttributeCenterX 80 | | MASAttributeCenterY | MASAttributeBaseline 81 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 82 | | MASAttributeFirstBaseline | MASAttributeLastBaseline 83 | #endif 84 | #if TARGET_OS_IPHONE || TARGET_OS_TV 85 | | MASAttributeLeftMargin | MASAttributeRightMargin | MASAttributeTopMargin | MASAttributeBottomMargin 86 | | MASAttributeLeadingMargin | MASAttributeTrailingMargin | MASAttributeCenterXWithinMargins 87 | | MASAttributeCenterYWithinMargins 88 | #endif 89 | ); 90 | 91 | NSAssert((attrs & anyAttribute) != 0, @"You didn't pass any attribute to make.attributes(...)"); 92 | 93 | NSMutableArray *attributes = [NSMutableArray array]; 94 | 95 | if (attrs & MASAttributeLeft) [attributes addObject:self.view.mas_left]; 96 | if (attrs & MASAttributeRight) [attributes addObject:self.view.mas_right]; 97 | if (attrs & MASAttributeTop) [attributes addObject:self.view.mas_top]; 98 | if (attrs & MASAttributeBottom) [attributes addObject:self.view.mas_bottom]; 99 | if (attrs & MASAttributeLeading) [attributes addObject:self.view.mas_leading]; 100 | if (attrs & MASAttributeTrailing) [attributes addObject:self.view.mas_trailing]; 101 | if (attrs & MASAttributeWidth) [attributes addObject:self.view.mas_width]; 102 | if (attrs & MASAttributeHeight) [attributes addObject:self.view.mas_height]; 103 | if (attrs & MASAttributeCenterX) [attributes addObject:self.view.mas_centerX]; 104 | if (attrs & MASAttributeCenterY) [attributes addObject:self.view.mas_centerY]; 105 | if (attrs & MASAttributeBaseline) [attributes addObject:self.view.mas_baseline]; 106 | 107 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 108 | 109 | if (attrs & MASAttributeFirstBaseline) [attributes addObject:self.view.mas_firstBaseline]; 110 | if (attrs & MASAttributeLastBaseline) [attributes addObject:self.view.mas_lastBaseline]; 111 | 112 | #endif 113 | 114 | #if TARGET_OS_IPHONE || TARGET_OS_TV 115 | 116 | if (attrs & MASAttributeLeftMargin) [attributes addObject:self.view.mas_leftMargin]; 117 | if (attrs & MASAttributeRightMargin) [attributes addObject:self.view.mas_rightMargin]; 118 | if (attrs & MASAttributeTopMargin) [attributes addObject:self.view.mas_topMargin]; 119 | if (attrs & MASAttributeBottomMargin) [attributes addObject:self.view.mas_bottomMargin]; 120 | if (attrs & MASAttributeLeadingMargin) [attributes addObject:self.view.mas_leadingMargin]; 121 | if (attrs & MASAttributeTrailingMargin) [attributes addObject:self.view.mas_trailingMargin]; 122 | if (attrs & MASAttributeCenterXWithinMargins) [attributes addObject:self.view.mas_centerXWithinMargins]; 123 | if (attrs & MASAttributeCenterYWithinMargins) [attributes addObject:self.view.mas_centerYWithinMargins]; 124 | 125 | #endif 126 | 127 | NSMutableArray *children = [NSMutableArray arrayWithCapacity:attributes.count]; 128 | 129 | for (MASViewAttribute *a in attributes) { 130 | [children addObject:[[MASViewConstraint alloc] initWithFirstViewAttribute:a]]; 131 | } 132 | 133 | MASCompositeConstraint *constraint = [[MASCompositeConstraint alloc] initWithChildren:children]; 134 | constraint.delegate = self; 135 | [self.constraints addObject:constraint]; 136 | return constraint; 137 | } 138 | 139 | #pragma mark - standard Attributes 140 | 141 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 142 | return [self constraint:nil addConstraintWithLayoutAttribute:layoutAttribute]; 143 | } 144 | 145 | - (MASConstraint *)left { 146 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeft]; 147 | } 148 | 149 | - (MASConstraint *)top { 150 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTop]; 151 | } 152 | 153 | - (MASConstraint *)right { 154 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRight]; 155 | } 156 | 157 | - (MASConstraint *)bottom { 158 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottom]; 159 | } 160 | 161 | - (MASConstraint *)leading { 162 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeading]; 163 | } 164 | 165 | - (MASConstraint *)trailing { 166 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailing]; 167 | } 168 | 169 | - (MASConstraint *)width { 170 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeWidth]; 171 | } 172 | 173 | - (MASConstraint *)height { 174 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeHeight]; 175 | } 176 | 177 | - (MASConstraint *)centerX { 178 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterX]; 179 | } 180 | 181 | - (MASConstraint *)centerY { 182 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterY]; 183 | } 184 | 185 | - (MASConstraint *)baseline { 186 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBaseline]; 187 | } 188 | 189 | - (MASConstraint *(^)(MASAttribute))attributes { 190 | return ^(MASAttribute attrs){ 191 | return [self addConstraintWithAttributes:attrs]; 192 | }; 193 | } 194 | 195 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 196 | 197 | - (MASConstraint *)firstBaseline { 198 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeFirstBaseline]; 199 | } 200 | 201 | - (MASConstraint *)lastBaseline { 202 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLastBaseline]; 203 | } 204 | 205 | #endif 206 | 207 | 208 | #if TARGET_OS_IPHONE || TARGET_OS_TV 209 | 210 | - (MASConstraint *)leftMargin { 211 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeftMargin]; 212 | } 213 | 214 | - (MASConstraint *)rightMargin { 215 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRightMargin]; 216 | } 217 | 218 | - (MASConstraint *)topMargin { 219 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTopMargin]; 220 | } 221 | 222 | - (MASConstraint *)bottomMargin { 223 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottomMargin]; 224 | } 225 | 226 | - (MASConstraint *)leadingMargin { 227 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeadingMargin]; 228 | } 229 | 230 | - (MASConstraint *)trailingMargin { 231 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailingMargin]; 232 | } 233 | 234 | - (MASConstraint *)centerXWithinMargins { 235 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterXWithinMargins]; 236 | } 237 | 238 | - (MASConstraint *)centerYWithinMargins { 239 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterYWithinMargins]; 240 | } 241 | 242 | #endif 243 | 244 | 245 | #pragma mark - composite Attributes 246 | 247 | - (MASConstraint *)edges { 248 | return [self addConstraintWithAttributes:MASAttributeTop | MASAttributeLeft | MASAttributeRight | MASAttributeBottom]; 249 | } 250 | 251 | - (MASConstraint *)size { 252 | return [self addConstraintWithAttributes:MASAttributeWidth | MASAttributeHeight]; 253 | } 254 | 255 | - (MASConstraint *)center { 256 | return [self addConstraintWithAttributes:MASAttributeCenterX | MASAttributeCenterY]; 257 | } 258 | 259 | #pragma mark - grouping 260 | 261 | - (MASConstraint *(^)(dispatch_block_t group))group { 262 | return ^id(dispatch_block_t group) { 263 | NSInteger previousCount = self.constraints.count; 264 | group(); 265 | 266 | NSArray *children = [self.constraints subarrayWithRange:NSMakeRange(previousCount, self.constraints.count - previousCount)]; 267 | MASCompositeConstraint *constraint = [[MASCompositeConstraint alloc] initWithChildren:children]; 268 | constraint.delegate = self; 269 | return constraint; 270 | }; 271 | } 272 | 273 | @end 274 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Masonry/Masonry/MASLayoutConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASLayoutConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * When you are debugging or printing the constraints attached to a view this subclass 13 | * makes it easier to identify which constraints have been created via Masonry 14 | */ 15 | @interface MASLayoutConstraint : NSLayoutConstraint 16 | 17 | /** 18 | * a key to associate with this constraint 19 | */ 20 | @property (nonatomic, strong) id mas_key; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Masonry/Masonry/MASLayoutConstraint.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASLayoutConstraint.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "MASLayoutConstraint.h" 10 | 11 | @implementation MASLayoutConstraint 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Masonry/Masonry/MASUtilities.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASUtilities.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 19/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | 13 | #if TARGET_OS_IPHONE || TARGET_OS_TV 14 | 15 | #import 16 | #define MAS_VIEW UIView 17 | #define MAS_VIEW_CONTROLLER UIViewController 18 | #define MASEdgeInsets UIEdgeInsets 19 | 20 | typedef UILayoutPriority MASLayoutPriority; 21 | static const MASLayoutPriority MASLayoutPriorityRequired = UILayoutPriorityRequired; 22 | static const MASLayoutPriority MASLayoutPriorityDefaultHigh = UILayoutPriorityDefaultHigh; 23 | static const MASLayoutPriority MASLayoutPriorityDefaultMedium = 500; 24 | static const MASLayoutPriority MASLayoutPriorityDefaultLow = UILayoutPriorityDefaultLow; 25 | static const MASLayoutPriority MASLayoutPriorityFittingSizeLevel = UILayoutPriorityFittingSizeLevel; 26 | 27 | #elif TARGET_OS_MAC 28 | 29 | #import 30 | #define MAS_VIEW NSView 31 | #define MASEdgeInsets NSEdgeInsets 32 | 33 | typedef NSLayoutPriority MASLayoutPriority; 34 | static const MASLayoutPriority MASLayoutPriorityRequired = NSLayoutPriorityRequired; 35 | static const MASLayoutPriority MASLayoutPriorityDefaultHigh = NSLayoutPriorityDefaultHigh; 36 | static const MASLayoutPriority MASLayoutPriorityDragThatCanResizeWindow = NSLayoutPriorityDragThatCanResizeWindow; 37 | static const MASLayoutPriority MASLayoutPriorityDefaultMedium = 501; 38 | static const MASLayoutPriority MASLayoutPriorityWindowSizeStayPut = NSLayoutPriorityWindowSizeStayPut; 39 | static const MASLayoutPriority MASLayoutPriorityDragThatCannotResizeWindow = NSLayoutPriorityDragThatCannotResizeWindow; 40 | static const MASLayoutPriority MASLayoutPriorityDefaultLow = NSLayoutPriorityDefaultLow; 41 | static const MASLayoutPriority MASLayoutPriorityFittingSizeCompression = NSLayoutPriorityFittingSizeCompression; 42 | 43 | #endif 44 | 45 | /** 46 | * Allows you to attach keys to objects matching the variable names passed. 47 | * 48 | * view1.mas_key = @"view1", view2.mas_key = @"view2"; 49 | * 50 | * is equivalent to: 51 | * 52 | * MASAttachKeys(view1, view2); 53 | */ 54 | #define MASAttachKeys(...) \ 55 | { \ 56 | NSDictionary *keyPairs = NSDictionaryOfVariableBindings(__VA_ARGS__); \ 57 | for (id key in keyPairs.allKeys) { \ 58 | id obj = keyPairs[key]; \ 59 | NSAssert([obj respondsToSelector:@selector(setMas_key:)], \ 60 | @"Cannot attach mas_key to %@", obj); \ 61 | [obj setMas_key:key]; \ 62 | } \ 63 | } 64 | 65 | /** 66 | * Used to create object hashes 67 | * Based on http://www.mikeash.com/pyblog/friday-qa-2010-06-18-implementing-equality-and-hashing.html 68 | */ 69 | #define MAS_NSUINT_BIT (CHAR_BIT * sizeof(NSUInteger)) 70 | #define MAS_NSUINTROTATE(val, howmuch) ((((NSUInteger)val) << howmuch) | (((NSUInteger)val) >> (MAS_NSUINT_BIT - howmuch))) 71 | 72 | /** 73 | * Given a scalar or struct value, wraps it in NSValue 74 | * Based on EXPObjectify: https://github.com/specta/expecta 75 | */ 76 | static inline id _MASBoxValue(const char *type, ...) { 77 | va_list v; 78 | va_start(v, type); 79 | id obj = nil; 80 | if (strcmp(type, @encode(id)) == 0) { 81 | id actual = va_arg(v, id); 82 | obj = actual; 83 | } else if (strcmp(type, @encode(CGPoint)) == 0) { 84 | CGPoint actual = (CGPoint)va_arg(v, CGPoint); 85 | obj = [NSValue value:&actual withObjCType:type]; 86 | } else if (strcmp(type, @encode(CGSize)) == 0) { 87 | CGSize actual = (CGSize)va_arg(v, CGSize); 88 | obj = [NSValue value:&actual withObjCType:type]; 89 | } else if (strcmp(type, @encode(MASEdgeInsets)) == 0) { 90 | MASEdgeInsets actual = (MASEdgeInsets)va_arg(v, MASEdgeInsets); 91 | obj = [NSValue value:&actual withObjCType:type]; 92 | } else if (strcmp(type, @encode(double)) == 0) { 93 | double actual = (double)va_arg(v, double); 94 | obj = [NSNumber numberWithDouble:actual]; 95 | } else if (strcmp(type, @encode(float)) == 0) { 96 | float actual = (float)va_arg(v, double); 97 | obj = [NSNumber numberWithFloat:actual]; 98 | } else if (strcmp(type, @encode(int)) == 0) { 99 | int actual = (int)va_arg(v, int); 100 | obj = [NSNumber numberWithInt:actual]; 101 | } else if (strcmp(type, @encode(long)) == 0) { 102 | long actual = (long)va_arg(v, long); 103 | obj = [NSNumber numberWithLong:actual]; 104 | } else if (strcmp(type, @encode(long long)) == 0) { 105 | long long actual = (long long)va_arg(v, long long); 106 | obj = [NSNumber numberWithLongLong:actual]; 107 | } else if (strcmp(type, @encode(short)) == 0) { 108 | short actual = (short)va_arg(v, int); 109 | obj = [NSNumber numberWithShort:actual]; 110 | } else if (strcmp(type, @encode(char)) == 0) { 111 | char actual = (char)va_arg(v, int); 112 | obj = [NSNumber numberWithChar:actual]; 113 | } else if (strcmp(type, @encode(bool)) == 0) { 114 | bool actual = (bool)va_arg(v, int); 115 | obj = [NSNumber numberWithBool:actual]; 116 | } else if (strcmp(type, @encode(unsigned char)) == 0) { 117 | unsigned char actual = (unsigned char)va_arg(v, unsigned int); 118 | obj = [NSNumber numberWithUnsignedChar:actual]; 119 | } else if (strcmp(type, @encode(unsigned int)) == 0) { 120 | unsigned int actual = (unsigned int)va_arg(v, unsigned int); 121 | obj = [NSNumber numberWithUnsignedInt:actual]; 122 | } else if (strcmp(type, @encode(unsigned long)) == 0) { 123 | unsigned long actual = (unsigned long)va_arg(v, unsigned long); 124 | obj = [NSNumber numberWithUnsignedLong:actual]; 125 | } else if (strcmp(type, @encode(unsigned long long)) == 0) { 126 | unsigned long long actual = (unsigned long long)va_arg(v, unsigned long long); 127 | obj = [NSNumber numberWithUnsignedLongLong:actual]; 128 | } else if (strcmp(type, @encode(unsigned short)) == 0) { 129 | unsigned short actual = (unsigned short)va_arg(v, unsigned int); 130 | obj = [NSNumber numberWithUnsignedShort:actual]; 131 | } 132 | va_end(v); 133 | return obj; 134 | } 135 | 136 | #define MASBoxValue(value) _MASBoxValue(@encode(__typeof__((value))), (value)) 137 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Masonry/Masonry/MASViewAttribute.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASAttribute.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * An immutable tuple which stores the view and the related NSLayoutAttribute. 13 | * Describes part of either the left or right hand side of a constraint equation 14 | */ 15 | @interface MASViewAttribute : NSObject 16 | 17 | /** 18 | * The view which the reciever relates to. Can be nil if item is not a view. 19 | */ 20 | @property (nonatomic, weak, readonly) MAS_VIEW *view; 21 | 22 | /** 23 | * The item which the reciever relates to. 24 | */ 25 | @property (nonatomic, weak, readonly) id item; 26 | 27 | /** 28 | * The attribute which the reciever relates to 29 | */ 30 | @property (nonatomic, assign, readonly) NSLayoutAttribute layoutAttribute; 31 | 32 | /** 33 | * Convenience initializer. 34 | */ 35 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute; 36 | 37 | /** 38 | * The designated initializer. 39 | */ 40 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute; 41 | 42 | /** 43 | * Determine whether the layoutAttribute is a size attribute 44 | * 45 | * @return YES if layoutAttribute is equal to NSLayoutAttributeWidth or NSLayoutAttributeHeight 46 | */ 47 | - (BOOL)isSizeAttribute; 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Masonry/Masonry/MASViewAttribute.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASAttribute.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASViewAttribute.h" 10 | 11 | @implementation MASViewAttribute 12 | 13 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute { 14 | self = [self initWithView:view item:view layoutAttribute:layoutAttribute]; 15 | return self; 16 | } 17 | 18 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute { 19 | self = [super init]; 20 | if (!self) return nil; 21 | 22 | _view = view; 23 | _item = item; 24 | _layoutAttribute = layoutAttribute; 25 | 26 | return self; 27 | } 28 | 29 | - (BOOL)isSizeAttribute { 30 | return self.layoutAttribute == NSLayoutAttributeWidth 31 | || self.layoutAttribute == NSLayoutAttributeHeight; 32 | } 33 | 34 | - (BOOL)isEqual:(MASViewAttribute *)viewAttribute { 35 | if ([viewAttribute isKindOfClass:self.class]) { 36 | return self.view == viewAttribute.view 37 | && self.layoutAttribute == viewAttribute.layoutAttribute; 38 | } 39 | return [super isEqual:viewAttribute]; 40 | } 41 | 42 | - (NSUInteger)hash { 43 | return MAS_NSUINTROTATE([self.view hash], MAS_NSUINT_BIT / 2) ^ self.layoutAttribute; 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Masonry/Masonry/MASViewConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASViewAttribute.h" 10 | #import "MASConstraint.h" 11 | #import "MASLayoutConstraint.h" 12 | #import "MASUtilities.h" 13 | 14 | /** 15 | * A single constraint. 16 | * Contains the attributes neccessary for creating a NSLayoutConstraint and adding it to the appropriate view 17 | */ 18 | @interface MASViewConstraint : MASConstraint 19 | 20 | /** 21 | * First item/view and first attribute of the NSLayoutConstraint 22 | */ 23 | @property (nonatomic, strong, readonly) MASViewAttribute *firstViewAttribute; 24 | 25 | /** 26 | * Second item/view and second attribute of the NSLayoutConstraint 27 | */ 28 | @property (nonatomic, strong, readonly) MASViewAttribute *secondViewAttribute; 29 | 30 | /** 31 | * initialises the MASViewConstraint with the first part of the equation 32 | * 33 | * @param firstViewAttribute view.mas_left, view.mas_width etc. 34 | * 35 | * @return a new view constraint 36 | */ 37 | - (id)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute; 38 | 39 | /** 40 | * Returns all MASViewConstraints installed with this view as a first item. 41 | * 42 | * @param view A view to retrieve constraints for. 43 | * 44 | * @return An array of MASViewConstraints. 45 | */ 46 | + (NSArray *)installedConstraintsForView:(MAS_VIEW *)view; 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Masonry/Masonry/Masonry.h: -------------------------------------------------------------------------------- 1 | // 2 | // Masonry.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for Masonry. 12 | FOUNDATION_EXPORT double MasonryVersionNumber; 13 | 14 | //! Project version string for Masonry. 15 | FOUNDATION_EXPORT const unsigned char MasonryVersionString[]; 16 | 17 | #import "MASUtilities.h" 18 | #import "View+MASAdditions.h" 19 | #import "View+MASShorthandAdditions.h" 20 | #import "ViewController+MASAdditions.h" 21 | #import "NSArray+MASAdditions.h" 22 | #import "NSArray+MASShorthandAdditions.h" 23 | #import "MASConstraint.h" 24 | #import "MASCompositeConstraint.h" 25 | #import "MASViewAttribute.h" 26 | #import "MASViewConstraint.h" 27 | #import "MASConstraintMaker.h" 28 | #import "MASLayoutConstraint.h" 29 | #import "NSLayoutConstraint+MASDebugAdditions.h" 30 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Masonry/Masonry/NSArray+MASAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+MASAdditions.h 3 | // 4 | // 5 | // Created by Daniel Hammond on 11/26/13. 6 | // 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | typedef NS_ENUM(NSUInteger, MASAxisType) { 14 | MASAxisTypeHorizontal, 15 | MASAxisTypeVertical 16 | }; 17 | 18 | @interface NSArray (MASAdditions) 19 | 20 | /** 21 | * Creates a MASConstraintMaker with each view in the callee. 22 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing on each view 23 | * 24 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 25 | * 26 | * @return Array of created MASConstraints 27 | */ 28 | - (NSArray *)mas_makeConstraints:(void (^)(MASConstraintMaker *make))block; 29 | 30 | /** 31 | * Creates a MASConstraintMaker with each view in the callee. 32 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view. 33 | * If an existing constraint exists then it will be updated instead. 34 | * 35 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 36 | * 37 | * @return Array of created/updated MASConstraints 38 | */ 39 | - (NSArray *)mas_updateConstraints:(void (^)(MASConstraintMaker *make))block; 40 | 41 | /** 42 | * Creates a MASConstraintMaker with each view in the callee. 43 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view. 44 | * All constraints previously installed for the views will be removed. 45 | * 46 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 47 | * 48 | * @return Array of created/updated MASConstraints 49 | */ 50 | - (NSArray *)mas_remakeConstraints:(void (^)(MASConstraintMaker *make))block; 51 | 52 | /** 53 | * distribute with fixed spacing 54 | * 55 | * @param axisType which axis to distribute items along 56 | * @param fixedSpacing the spacing between each item 57 | * @param leadSpacing the spacing before the first item and the container 58 | * @param tailSpacing the spacing after the last item and the container 59 | */ 60 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedSpacing:(CGFloat)fixedSpacing leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing; 61 | 62 | /** 63 | * distribute with fixed item size 64 | * 65 | * @param axisType which axis to distribute items along 66 | * @param fixedItemLength the fixed length of each item 67 | * @param leadSpacing the spacing before the first item and the container 68 | * @param tailSpacing the spacing after the last item and the container 69 | */ 70 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedItemLength:(CGFloat)fixedItemLength leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing; 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Masonry/Masonry/NSArray+MASAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+MASAdditions.m 3 | // 4 | // 5 | // Created by Daniel Hammond on 11/26/13. 6 | // 7 | // 8 | 9 | #import "NSArray+MASAdditions.h" 10 | #import "View+MASAdditions.h" 11 | 12 | @implementation NSArray (MASAdditions) 13 | 14 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block { 15 | NSMutableArray *constraints = [NSMutableArray array]; 16 | for (MAS_VIEW *view in self) { 17 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views"); 18 | [constraints addObjectsFromArray:[view mas_makeConstraints:block]]; 19 | } 20 | return constraints; 21 | } 22 | 23 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *make))block { 24 | NSMutableArray *constraints = [NSMutableArray array]; 25 | for (MAS_VIEW *view in self) { 26 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views"); 27 | [constraints addObjectsFromArray:[view mas_updateConstraints:block]]; 28 | } 29 | return constraints; 30 | } 31 | 32 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block { 33 | NSMutableArray *constraints = [NSMutableArray array]; 34 | for (MAS_VIEW *view in self) { 35 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views"); 36 | [constraints addObjectsFromArray:[view mas_remakeConstraints:block]]; 37 | } 38 | return constraints; 39 | } 40 | 41 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedSpacing:(CGFloat)fixedSpacing leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing { 42 | if (self.count < 2) { 43 | NSAssert(self.count>1,@"views to distribute need to bigger than one"); 44 | return; 45 | } 46 | 47 | MAS_VIEW *tempSuperView = [self mas_commonSuperviewOfViews]; 48 | if (axisType == MASAxisTypeHorizontal) { 49 | MAS_VIEW *prev; 50 | for (int i = 0; i < self.count; i++) { 51 | MAS_VIEW *v = self[i]; 52 | [v mas_makeConstraints:^(MASConstraintMaker *make) { 53 | if (prev) { 54 | make.width.equalTo(prev); 55 | make.left.equalTo(prev.mas_right).offset(fixedSpacing); 56 | if (i == self.count - 1) {//last one 57 | make.right.equalTo(tempSuperView).offset(-tailSpacing); 58 | } 59 | } 60 | else {//first one 61 | make.left.equalTo(tempSuperView).offset(leadSpacing); 62 | } 63 | 64 | }]; 65 | prev = v; 66 | } 67 | } 68 | else { 69 | MAS_VIEW *prev; 70 | for (int i = 0; i < self.count; i++) { 71 | MAS_VIEW *v = self[i]; 72 | [v mas_makeConstraints:^(MASConstraintMaker *make) { 73 | if (prev) { 74 | make.height.equalTo(prev); 75 | make.top.equalTo(prev.mas_bottom).offset(fixedSpacing); 76 | if (i == self.count - 1) {//last one 77 | make.bottom.equalTo(tempSuperView).offset(-tailSpacing); 78 | } 79 | } 80 | else {//first one 81 | make.top.equalTo(tempSuperView).offset(leadSpacing); 82 | } 83 | 84 | }]; 85 | prev = v; 86 | } 87 | } 88 | } 89 | 90 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedItemLength:(CGFloat)fixedItemLength leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing { 91 | if (self.count < 2) { 92 | NSAssert(self.count>1,@"views to distribute need to bigger than one"); 93 | return; 94 | } 95 | 96 | MAS_VIEW *tempSuperView = [self mas_commonSuperviewOfViews]; 97 | if (axisType == MASAxisTypeHorizontal) { 98 | MAS_VIEW *prev; 99 | for (int i = 0; i < self.count; i++) { 100 | MAS_VIEW *v = self[i]; 101 | [v mas_makeConstraints:^(MASConstraintMaker *make) { 102 | make.width.equalTo(@(fixedItemLength)); 103 | if (prev) { 104 | if (i == self.count - 1) {//last one 105 | make.right.equalTo(tempSuperView).offset(-tailSpacing); 106 | } 107 | else { 108 | CGFloat offset = (1-(i/((CGFloat)self.count-1)))*(fixedItemLength+leadSpacing)-i*tailSpacing/(((CGFloat)self.count-1)); 109 | make.right.equalTo(tempSuperView).multipliedBy(i/((CGFloat)self.count-1)).with.offset(offset); 110 | } 111 | } 112 | else {//first one 113 | make.left.equalTo(tempSuperView).offset(leadSpacing); 114 | } 115 | }]; 116 | prev = v; 117 | } 118 | } 119 | else { 120 | MAS_VIEW *prev; 121 | for (int i = 0; i < self.count; i++) { 122 | MAS_VIEW *v = self[i]; 123 | [v mas_makeConstraints:^(MASConstraintMaker *make) { 124 | make.height.equalTo(@(fixedItemLength)); 125 | if (prev) { 126 | if (i == self.count - 1) {//last one 127 | make.bottom.equalTo(tempSuperView).offset(-tailSpacing); 128 | } 129 | else { 130 | CGFloat offset = (1-(i/((CGFloat)self.count-1)))*(fixedItemLength+leadSpacing)-i*tailSpacing/(((CGFloat)self.count-1)); 131 | make.bottom.equalTo(tempSuperView).multipliedBy(i/((CGFloat)self.count-1)).with.offset(offset); 132 | } 133 | } 134 | else {//first one 135 | make.top.equalTo(tempSuperView).offset(leadSpacing); 136 | } 137 | }]; 138 | prev = v; 139 | } 140 | } 141 | } 142 | 143 | - (MAS_VIEW *)mas_commonSuperviewOfViews 144 | { 145 | MAS_VIEW *commonSuperview = nil; 146 | MAS_VIEW *previousView = nil; 147 | for (id object in self) { 148 | if ([object isKindOfClass:[MAS_VIEW class]]) { 149 | MAS_VIEW *view = (MAS_VIEW *)object; 150 | if (previousView) { 151 | commonSuperview = [view mas_closestCommonSuperview:commonSuperview]; 152 | } else { 153 | commonSuperview = view; 154 | } 155 | previousView = view; 156 | } 157 | } 158 | NSAssert(commonSuperview, @"Can't constrain views that do not share a common superview. Make sure that all the views in this array have been added into the same view hierarchy."); 159 | return commonSuperview; 160 | } 161 | 162 | @end 163 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Masonry/Masonry/NSArray+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+MASShorthandAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 22/07/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "NSArray+MASAdditions.h" 10 | 11 | #ifdef MAS_SHORTHAND 12 | 13 | /** 14 | * Shorthand array additions without the 'mas_' prefixes, 15 | * only enabled if MAS_SHORTHAND is defined 16 | */ 17 | @interface NSArray (MASShorthandAdditions) 18 | 19 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block; 20 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block; 21 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block; 22 | 23 | @end 24 | 25 | @implementation NSArray (MASShorthandAdditions) 26 | 27 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *))block { 28 | return [self mas_makeConstraints:block]; 29 | } 30 | 31 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *))block { 32 | return [self mas_updateConstraints:block]; 33 | } 34 | 35 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *))block { 36 | return [self mas_remakeConstraints:block]; 37 | } 38 | 39 | @end 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Masonry/Masonry/NSLayoutConstraint+MASDebugAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSLayoutConstraint+MASDebugAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * makes debug and log output of NSLayoutConstraints more readable 13 | */ 14 | @interface NSLayoutConstraint (MASDebugAdditions) 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Masonry/Masonry/NSLayoutConstraint+MASDebugAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSLayoutConstraint+MASDebugAdditions.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "NSLayoutConstraint+MASDebugAdditions.h" 10 | #import "MASConstraint.h" 11 | #import "MASLayoutConstraint.h" 12 | 13 | @implementation NSLayoutConstraint (MASDebugAdditions) 14 | 15 | #pragma mark - description maps 16 | 17 | + (NSDictionary *)layoutRelationDescriptionsByValue { 18 | static dispatch_once_t once; 19 | static NSDictionary *descriptionMap; 20 | dispatch_once(&once, ^{ 21 | descriptionMap = @{ 22 | @(NSLayoutRelationEqual) : @"==", 23 | @(NSLayoutRelationGreaterThanOrEqual) : @">=", 24 | @(NSLayoutRelationLessThanOrEqual) : @"<=", 25 | }; 26 | }); 27 | return descriptionMap; 28 | } 29 | 30 | + (NSDictionary *)layoutAttributeDescriptionsByValue { 31 | static dispatch_once_t once; 32 | static NSDictionary *descriptionMap; 33 | dispatch_once(&once, ^{ 34 | descriptionMap = @{ 35 | @(NSLayoutAttributeTop) : @"top", 36 | @(NSLayoutAttributeLeft) : @"left", 37 | @(NSLayoutAttributeBottom) : @"bottom", 38 | @(NSLayoutAttributeRight) : @"right", 39 | @(NSLayoutAttributeLeading) : @"leading", 40 | @(NSLayoutAttributeTrailing) : @"trailing", 41 | @(NSLayoutAttributeWidth) : @"width", 42 | @(NSLayoutAttributeHeight) : @"height", 43 | @(NSLayoutAttributeCenterX) : @"centerX", 44 | @(NSLayoutAttributeCenterY) : @"centerY", 45 | @(NSLayoutAttributeBaseline) : @"baseline", 46 | 47 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 48 | @(NSLayoutAttributeFirstBaseline) : @"firstBaseline", 49 | @(NSLayoutAttributeLastBaseline) : @"lastBaseline", 50 | #endif 51 | 52 | #if TARGET_OS_IPHONE || TARGET_OS_TV 53 | @(NSLayoutAttributeLeftMargin) : @"leftMargin", 54 | @(NSLayoutAttributeRightMargin) : @"rightMargin", 55 | @(NSLayoutAttributeTopMargin) : @"topMargin", 56 | @(NSLayoutAttributeBottomMargin) : @"bottomMargin", 57 | @(NSLayoutAttributeLeadingMargin) : @"leadingMargin", 58 | @(NSLayoutAttributeTrailingMargin) : @"trailingMargin", 59 | @(NSLayoutAttributeCenterXWithinMargins) : @"centerXWithinMargins", 60 | @(NSLayoutAttributeCenterYWithinMargins) : @"centerYWithinMargins", 61 | #endif 62 | 63 | }; 64 | 65 | }); 66 | return descriptionMap; 67 | } 68 | 69 | 70 | + (NSDictionary *)layoutPriorityDescriptionsByValue { 71 | static dispatch_once_t once; 72 | static NSDictionary *descriptionMap; 73 | dispatch_once(&once, ^{ 74 | #if TARGET_OS_IPHONE || TARGET_OS_TV 75 | descriptionMap = @{ 76 | @(MASLayoutPriorityDefaultHigh) : @"high", 77 | @(MASLayoutPriorityDefaultLow) : @"low", 78 | @(MASLayoutPriorityDefaultMedium) : @"medium", 79 | @(MASLayoutPriorityRequired) : @"required", 80 | @(MASLayoutPriorityFittingSizeLevel) : @"fitting size", 81 | }; 82 | #elif TARGET_OS_MAC 83 | descriptionMap = @{ 84 | @(MASLayoutPriorityDefaultHigh) : @"high", 85 | @(MASLayoutPriorityDragThatCanResizeWindow) : @"drag can resize window", 86 | @(MASLayoutPriorityDefaultMedium) : @"medium", 87 | @(MASLayoutPriorityWindowSizeStayPut) : @"window size stay put", 88 | @(MASLayoutPriorityDragThatCannotResizeWindow) : @"drag cannot resize window", 89 | @(MASLayoutPriorityDefaultLow) : @"low", 90 | @(MASLayoutPriorityFittingSizeCompression) : @"fitting size", 91 | @(MASLayoutPriorityRequired) : @"required", 92 | }; 93 | #endif 94 | }); 95 | return descriptionMap; 96 | } 97 | 98 | #pragma mark - description override 99 | 100 | + (NSString *)descriptionForObject:(id)obj { 101 | if ([obj respondsToSelector:@selector(mas_key)] && [obj mas_key]) { 102 | return [NSString stringWithFormat:@"%@:%@", [obj class], [obj mas_key]]; 103 | } 104 | return [NSString stringWithFormat:@"%@:%p", [obj class], obj]; 105 | } 106 | 107 | - (NSString *)description { 108 | NSMutableString *description = [[NSMutableString alloc] initWithString:@"<"]; 109 | 110 | [description appendString:[self.class descriptionForObject:self]]; 111 | 112 | [description appendFormat:@" %@", [self.class descriptionForObject:self.firstItem]]; 113 | if (self.firstAttribute != NSLayoutAttributeNotAnAttribute) { 114 | [description appendFormat:@".%@", self.class.layoutAttributeDescriptionsByValue[@(self.firstAttribute)]]; 115 | } 116 | 117 | [description appendFormat:@" %@", self.class.layoutRelationDescriptionsByValue[@(self.relation)]]; 118 | 119 | if (self.secondItem) { 120 | [description appendFormat:@" %@", [self.class descriptionForObject:self.secondItem]]; 121 | } 122 | if (self.secondAttribute != NSLayoutAttributeNotAnAttribute) { 123 | [description appendFormat:@".%@", self.class.layoutAttributeDescriptionsByValue[@(self.secondAttribute)]]; 124 | } 125 | 126 | if (self.multiplier != 1) { 127 | [description appendFormat:@" * %g", self.multiplier]; 128 | } 129 | 130 | if (self.secondAttribute == NSLayoutAttributeNotAnAttribute) { 131 | [description appendFormat:@" %g", self.constant]; 132 | } else { 133 | if (self.constant) { 134 | [description appendFormat:@" %@ %g", (self.constant < 0 ? @"-" : @"+"), ABS(self.constant)]; 135 | } 136 | } 137 | 138 | if (self.priority != MASLayoutPriorityRequired) { 139 | [description appendFormat:@" ^%@", self.class.layoutPriorityDescriptionsByValue[@(self.priority)] ?: [NSNumber numberWithDouble:self.priority]]; 140 | } 141 | 142 | [description appendString:@">"]; 143 | return description; 144 | } 145 | 146 | @end 147 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Masonry/Masonry/View+MASAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | /** 14 | * Provides constraint maker block 15 | * and convience methods for creating MASViewAttribute which are view + NSLayoutAttribute pairs 16 | */ 17 | @interface MAS_VIEW (MASAdditions) 18 | 19 | /** 20 | * following properties return a new MASViewAttribute with current view and appropriate NSLayoutAttribute 21 | */ 22 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_left; 23 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_top; 24 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_right; 25 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottom; 26 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leading; 27 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_trailing; 28 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_width; 29 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_height; 30 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerX; 31 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerY; 32 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_baseline; 33 | @property (nonatomic, strong, readonly) MASViewAttribute *(^mas_attribute)(NSLayoutAttribute attr); 34 | 35 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 36 | 37 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_firstBaseline; 38 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_lastBaseline; 39 | 40 | #endif 41 | 42 | #if TARGET_OS_IPHONE || TARGET_OS_TV 43 | 44 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leftMargin; 45 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_rightMargin; 46 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topMargin; 47 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomMargin; 48 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leadingMargin; 49 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_trailingMargin; 50 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerXWithinMargins; 51 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerYWithinMargins; 52 | 53 | #endif 54 | 55 | /** 56 | * a key to associate with this view 57 | */ 58 | @property (nonatomic, strong) id mas_key; 59 | 60 | /** 61 | * Finds the closest common superview between this view and another view 62 | * 63 | * @param view other view 64 | * 65 | * @return returns nil if common superview could not be found 66 | */ 67 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view; 68 | 69 | /** 70 | * Creates a MASConstraintMaker with the callee view. 71 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing 72 | * 73 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 74 | * 75 | * @return Array of created MASConstraints 76 | */ 77 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block; 78 | 79 | /** 80 | * Creates a MASConstraintMaker with the callee view. 81 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 82 | * If an existing constraint exists then it will be updated instead. 83 | * 84 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 85 | * 86 | * @return Array of created/updated MASConstraints 87 | */ 88 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *make))block; 89 | 90 | /** 91 | * Creates a MASConstraintMaker with the callee view. 92 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 93 | * All constraints previously installed for the view will be removed. 94 | * 95 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 96 | * 97 | * @return Array of created/updated MASConstraints 98 | */ 99 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block; 100 | 101 | @end 102 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Masonry/Masonry/View+MASAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASAdditions.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "View+MASAdditions.h" 10 | #import 11 | 12 | @implementation MAS_VIEW (MASAdditions) 13 | 14 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *))block { 15 | self.translatesAutoresizingMaskIntoConstraints = NO; 16 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 17 | block(constraintMaker); 18 | return [constraintMaker install]; 19 | } 20 | 21 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *))block { 22 | self.translatesAutoresizingMaskIntoConstraints = NO; 23 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 24 | constraintMaker.updateExisting = YES; 25 | block(constraintMaker); 26 | return [constraintMaker install]; 27 | } 28 | 29 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block { 30 | self.translatesAutoresizingMaskIntoConstraints = NO; 31 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 32 | constraintMaker.removeExisting = YES; 33 | block(constraintMaker); 34 | return [constraintMaker install]; 35 | } 36 | 37 | #pragma mark - NSLayoutAttribute properties 38 | 39 | - (MASViewAttribute *)mas_left { 40 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeft]; 41 | } 42 | 43 | - (MASViewAttribute *)mas_top { 44 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTop]; 45 | } 46 | 47 | - (MASViewAttribute *)mas_right { 48 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeRight]; 49 | } 50 | 51 | - (MASViewAttribute *)mas_bottom { 52 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottom]; 53 | } 54 | 55 | - (MASViewAttribute *)mas_leading { 56 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeading]; 57 | } 58 | 59 | - (MASViewAttribute *)mas_trailing { 60 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTrailing]; 61 | } 62 | 63 | - (MASViewAttribute *)mas_width { 64 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeWidth]; 65 | } 66 | 67 | - (MASViewAttribute *)mas_height { 68 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeHeight]; 69 | } 70 | 71 | - (MASViewAttribute *)mas_centerX { 72 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterX]; 73 | } 74 | 75 | - (MASViewAttribute *)mas_centerY { 76 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterY]; 77 | } 78 | 79 | - (MASViewAttribute *)mas_baseline { 80 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBaseline]; 81 | } 82 | 83 | - (MASViewAttribute *(^)(NSLayoutAttribute))mas_attribute 84 | { 85 | return ^(NSLayoutAttribute attr) { 86 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:attr]; 87 | }; 88 | } 89 | 90 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 91 | 92 | - (MASViewAttribute *)mas_firstBaseline { 93 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeFirstBaseline]; 94 | } 95 | - (MASViewAttribute *)mas_lastBaseline { 96 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLastBaseline]; 97 | } 98 | 99 | #endif 100 | 101 | #if TARGET_OS_IPHONE || TARGET_OS_TV 102 | 103 | - (MASViewAttribute *)mas_leftMargin { 104 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeftMargin]; 105 | } 106 | 107 | - (MASViewAttribute *)mas_rightMargin { 108 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeRightMargin]; 109 | } 110 | 111 | - (MASViewAttribute *)mas_topMargin { 112 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTopMargin]; 113 | } 114 | 115 | - (MASViewAttribute *)mas_bottomMargin { 116 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottomMargin]; 117 | } 118 | 119 | - (MASViewAttribute *)mas_leadingMargin { 120 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeadingMargin]; 121 | } 122 | 123 | - (MASViewAttribute *)mas_trailingMargin { 124 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTrailingMargin]; 125 | } 126 | 127 | - (MASViewAttribute *)mas_centerXWithinMargins { 128 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterXWithinMargins]; 129 | } 130 | 131 | - (MASViewAttribute *)mas_centerYWithinMargins { 132 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterYWithinMargins]; 133 | } 134 | 135 | #endif 136 | 137 | #pragma mark - associated properties 138 | 139 | - (id)mas_key { 140 | return objc_getAssociatedObject(self, @selector(mas_key)); 141 | } 142 | 143 | - (void)setMas_key:(id)key { 144 | objc_setAssociatedObject(self, @selector(mas_key), key, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 145 | } 146 | 147 | #pragma mark - heirachy 148 | 149 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view { 150 | MAS_VIEW *closestCommonSuperview = nil; 151 | 152 | MAS_VIEW *secondViewSuperview = view; 153 | while (!closestCommonSuperview && secondViewSuperview) { 154 | MAS_VIEW *firstViewSuperview = self; 155 | while (!closestCommonSuperview && firstViewSuperview) { 156 | if (secondViewSuperview == firstViewSuperview) { 157 | closestCommonSuperview = secondViewSuperview; 158 | } 159 | firstViewSuperview = firstViewSuperview.superview; 160 | } 161 | secondViewSuperview = secondViewSuperview.superview; 162 | } 163 | return closestCommonSuperview; 164 | } 165 | 166 | @end 167 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Masonry/Masonry/View+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASShorthandAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 22/07/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "View+MASAdditions.h" 10 | 11 | #ifdef MAS_SHORTHAND 12 | 13 | /** 14 | * Shorthand view additions without the 'mas_' prefixes, 15 | * only enabled if MAS_SHORTHAND is defined 16 | */ 17 | @interface MAS_VIEW (MASShorthandAdditions) 18 | 19 | @property (nonatomic, strong, readonly) MASViewAttribute *left; 20 | @property (nonatomic, strong, readonly) MASViewAttribute *top; 21 | @property (nonatomic, strong, readonly) MASViewAttribute *right; 22 | @property (nonatomic, strong, readonly) MASViewAttribute *bottom; 23 | @property (nonatomic, strong, readonly) MASViewAttribute *leading; 24 | @property (nonatomic, strong, readonly) MASViewAttribute *trailing; 25 | @property (nonatomic, strong, readonly) MASViewAttribute *width; 26 | @property (nonatomic, strong, readonly) MASViewAttribute *height; 27 | @property (nonatomic, strong, readonly) MASViewAttribute *centerX; 28 | @property (nonatomic, strong, readonly) MASViewAttribute *centerY; 29 | @property (nonatomic, strong, readonly) MASViewAttribute *baseline; 30 | @property (nonatomic, strong, readonly) MASViewAttribute *(^attribute)(NSLayoutAttribute attr); 31 | 32 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 33 | 34 | @property (nonatomic, strong, readonly) MASViewAttribute *firstBaseline; 35 | @property (nonatomic, strong, readonly) MASViewAttribute *lastBaseline; 36 | 37 | #endif 38 | 39 | #if TARGET_OS_IPHONE || TARGET_OS_TV 40 | 41 | @property (nonatomic, strong, readonly) MASViewAttribute *leftMargin; 42 | @property (nonatomic, strong, readonly) MASViewAttribute *rightMargin; 43 | @property (nonatomic, strong, readonly) MASViewAttribute *topMargin; 44 | @property (nonatomic, strong, readonly) MASViewAttribute *bottomMargin; 45 | @property (nonatomic, strong, readonly) MASViewAttribute *leadingMargin; 46 | @property (nonatomic, strong, readonly) MASViewAttribute *trailingMargin; 47 | @property (nonatomic, strong, readonly) MASViewAttribute *centerXWithinMargins; 48 | @property (nonatomic, strong, readonly) MASViewAttribute *centerYWithinMargins; 49 | 50 | #endif 51 | 52 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block; 53 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block; 54 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block; 55 | 56 | @end 57 | 58 | #define MAS_ATTR_FORWARD(attr) \ 59 | - (MASViewAttribute *)attr { \ 60 | return [self mas_##attr]; \ 61 | } 62 | 63 | @implementation MAS_VIEW (MASShorthandAdditions) 64 | 65 | MAS_ATTR_FORWARD(top); 66 | MAS_ATTR_FORWARD(left); 67 | MAS_ATTR_FORWARD(bottom); 68 | MAS_ATTR_FORWARD(right); 69 | MAS_ATTR_FORWARD(leading); 70 | MAS_ATTR_FORWARD(trailing); 71 | MAS_ATTR_FORWARD(width); 72 | MAS_ATTR_FORWARD(height); 73 | MAS_ATTR_FORWARD(centerX); 74 | MAS_ATTR_FORWARD(centerY); 75 | MAS_ATTR_FORWARD(baseline); 76 | 77 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 78 | 79 | MAS_ATTR_FORWARD(firstBaseline); 80 | MAS_ATTR_FORWARD(lastBaseline); 81 | 82 | #endif 83 | 84 | #if TARGET_OS_IPHONE || TARGET_OS_TV 85 | 86 | MAS_ATTR_FORWARD(leftMargin); 87 | MAS_ATTR_FORWARD(rightMargin); 88 | MAS_ATTR_FORWARD(topMargin); 89 | MAS_ATTR_FORWARD(bottomMargin); 90 | MAS_ATTR_FORWARD(leadingMargin); 91 | MAS_ATTR_FORWARD(trailingMargin); 92 | MAS_ATTR_FORWARD(centerXWithinMargins); 93 | MAS_ATTR_FORWARD(centerYWithinMargins); 94 | 95 | #endif 96 | 97 | - (MASViewAttribute *(^)(NSLayoutAttribute))attribute { 98 | return [self mas_attribute]; 99 | } 100 | 101 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *))block { 102 | return [self mas_makeConstraints:block]; 103 | } 104 | 105 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *))block { 106 | return [self mas_updateConstraints:block]; 107 | } 108 | 109 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *))block { 110 | return [self mas_remakeConstraints:block]; 111 | } 112 | 113 | @end 114 | 115 | #endif 116 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Masonry/Masonry/ViewController+MASAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+MASAdditions.h 3 | // Masonry 4 | // 5 | // Created by Craig Siemens on 2015-06-23. 6 | // 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | #ifdef MAS_VIEW_CONTROLLER 14 | 15 | @interface MAS_VIEW_CONTROLLER (MASAdditions) 16 | 17 | /** 18 | * following properties return a new MASViewAttribute with appropriate UILayoutGuide and NSLayoutAttribute 19 | */ 20 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuide; 21 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuide; 22 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuideTop; 23 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuideBottom; 24 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuideTop; 25 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuideBottom; 26 | 27 | 28 | @end 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Masonry/Masonry/ViewController+MASAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+MASAdditions.m 3 | // Masonry 4 | // 5 | // Created by Craig Siemens on 2015-06-23. 6 | // 7 | // 8 | 9 | #import "ViewController+MASAdditions.h" 10 | 11 | #ifdef MAS_VIEW_CONTROLLER 12 | 13 | @implementation MAS_VIEW_CONTROLLER (MASAdditions) 14 | 15 | - (MASViewAttribute *)mas_topLayoutGuide { 16 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 17 | } 18 | - (MASViewAttribute *)mas_topLayoutGuideTop { 19 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 20 | } 21 | - (MASViewAttribute *)mas_topLayoutGuideBottom { 22 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 23 | } 24 | 25 | - (MASViewAttribute *)mas_bottomLayoutGuide { 26 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 27 | } 28 | - (MASViewAttribute *)mas_bottomLayoutGuideTop { 29 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 30 | } 31 | - (MASViewAttribute *)mas_bottomLayoutGuideBottom { 32 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 33 | } 34 | 35 | 36 | 37 | @end 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Target Support Files/Masonry/Masonry-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Masonry : NSObject 3 | @end 4 | @implementation PodsDummy_Masonry 5 | @end 6 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Target Support Files/Masonry/Masonry-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Target Support Files/Masonry/Masonry.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/Masonry 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/Masonry" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/Masonry" 4 | OTHER_LDFLAGS = -framework "Foundation" -framework "UIKit" 5 | PODS_BUILD_DIR = $BUILD_DIR 6 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT} 8 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/Masonry 9 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 10 | SKIP_INSTALL = YES 11 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Target Support Files/Pods-JHPageMenuViewDemo/Pods-JHPageMenuViewDemo-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## Masonry 5 | 6 | Copyright (c) 2011-2012 Masonry Team - https://github.com/Masonry 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | Generated by CocoaPods - https://cocoapods.org 26 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Target Support Files/Pods-JHPageMenuViewDemo/Pods-JHPageMenuViewDemo-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Copyright (c) 2011-2012 Masonry Team - https://github.com/Masonry 18 | 19 | Permission is hereby granted, free of charge, to any person obtaining a copy 20 | of this software and associated documentation files (the "Software"), to deal 21 | in the Software without restriction, including without limitation the rights 22 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 23 | copies of the Software, and to permit persons to whom the Software is 24 | furnished to do so, subject to the following conditions: 25 | 26 | The above copyright notice and this permission notice shall be included in 27 | all copies or substantial portions of the Software. 28 | 29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 35 | THE SOFTWARE. 36 | License 37 | MIT 38 | Title 39 | Masonry 40 | Type 41 | PSGroupSpecifier 42 | 43 | 44 | FooterText 45 | Generated by CocoaPods - https://cocoapods.org 46 | Title 47 | 48 | Type 49 | PSGroupSpecifier 50 | 51 | 52 | StringsTable 53 | Acknowledgements 54 | Title 55 | Acknowledgements 56 | 57 | 58 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Target Support Files/Pods-JHPageMenuViewDemo/Pods-JHPageMenuViewDemo-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_JHPageMenuViewDemo : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_JHPageMenuViewDemo 5 | @end 6 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Target Support Files/Pods-JHPageMenuViewDemo/Pods-JHPageMenuViewDemo-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | # This protects against multiple targets copying the same framework dependency at the same time. The solution 10 | # was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html 11 | RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????") 12 | 13 | install_framework() 14 | { 15 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 16 | local source="${BUILT_PRODUCTS_DIR}/$1" 17 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 18 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 19 | elif [ -r "$1" ]; then 20 | local source="$1" 21 | fi 22 | 23 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 24 | 25 | if [ -L "${source}" ]; then 26 | echo "Symlinked..." 27 | source="$(readlink "${source}")" 28 | fi 29 | 30 | # Use filter instead of exclude so missing patterns don't throw errors. 31 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 32 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 33 | 34 | local basename 35 | basename="$(basename -s .framework "$1")" 36 | binary="${destination}/${basename}.framework/${basename}" 37 | if ! [ -r "$binary" ]; then 38 | binary="${destination}/${basename}" 39 | fi 40 | 41 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 42 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 43 | strip_invalid_archs "$binary" 44 | fi 45 | 46 | # Resign the code if required by the build settings to avoid unstable apps 47 | code_sign_if_enabled "${destination}/$(basename "$1")" 48 | 49 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 50 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 51 | local swift_runtime_libs 52 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 53 | for lib in $swift_runtime_libs; do 54 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 55 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 56 | code_sign_if_enabled "${destination}/${lib}" 57 | done 58 | fi 59 | } 60 | 61 | # Copies the dSYM of a vendored framework 62 | install_dsym() { 63 | local source="$1" 64 | if [ -r "$source" ]; then 65 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${DWARF_DSYM_FOLDER_PATH}\"" 66 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${DWARF_DSYM_FOLDER_PATH}" 67 | fi 68 | } 69 | 70 | # Signs a framework with the provided identity 71 | code_sign_if_enabled() { 72 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 73 | # Use the current code_sign_identitiy 74 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 75 | local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements '$1'" 76 | 77 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 78 | code_sign_cmd="$code_sign_cmd &" 79 | fi 80 | echo "$code_sign_cmd" 81 | eval "$code_sign_cmd" 82 | fi 83 | } 84 | 85 | # Strip invalid architectures 86 | strip_invalid_archs() { 87 | binary="$1" 88 | # Get architectures for current file 89 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" 90 | stripped="" 91 | for arch in $archs; do 92 | if ! [[ "${ARCHS}" == *"$arch"* ]]; then 93 | # Strip non-valid architectures in-place 94 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 95 | stripped="$stripped $arch" 96 | fi 97 | done 98 | if [[ "$stripped" ]]; then 99 | echo "Stripped $binary of architectures:$stripped" 100 | fi 101 | } 102 | 103 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 104 | wait 105 | fi 106 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Target Support Files/Pods-JHPageMenuViewDemo/Pods-JHPageMenuViewDemo-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES=() 10 | 11 | # This protects against multiple targets copying the same framework dependency at the same time. The solution 12 | # was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html 13 | RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????") 14 | 15 | case "${TARGETED_DEVICE_FAMILY}" in 16 | 1,2) 17 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 18 | ;; 19 | 1) 20 | TARGET_DEVICE_ARGS="--target-device iphone" 21 | ;; 22 | 2) 23 | TARGET_DEVICE_ARGS="--target-device ipad" 24 | ;; 25 | 3) 26 | TARGET_DEVICE_ARGS="--target-device tv" 27 | ;; 28 | 4) 29 | TARGET_DEVICE_ARGS="--target-device watch" 30 | ;; 31 | *) 32 | TARGET_DEVICE_ARGS="--target-device mac" 33 | ;; 34 | esac 35 | 36 | install_resource() 37 | { 38 | if [[ "$1" = /* ]] ; then 39 | RESOURCE_PATH="$1" 40 | else 41 | RESOURCE_PATH="${PODS_ROOT}/$1" 42 | fi 43 | if [[ ! -e "$RESOURCE_PATH" ]] ; then 44 | cat << EOM 45 | error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script. 46 | EOM 47 | exit 1 48 | fi 49 | case $RESOURCE_PATH in 50 | *.storyboard) 51 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" || true 52 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 53 | ;; 54 | *.xib) 55 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" || true 56 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 57 | ;; 58 | *.framework) 59 | echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" || true 60 | mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 61 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" || true 62 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 63 | ;; 64 | *.xcdatamodel) 65 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" || true 66 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" 67 | ;; 68 | *.xcdatamodeld) 69 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" || true 70 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" 71 | ;; 72 | *.xcmappingmodel) 73 | echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" || true 74 | xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" 75 | ;; 76 | *.xcassets) 77 | ABSOLUTE_XCASSET_FILE="$RESOURCE_PATH" 78 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 79 | ;; 80 | *) 81 | echo "$RESOURCE_PATH" || true 82 | echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" 83 | ;; 84 | esac 85 | } 86 | 87 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 88 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 89 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then 90 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 91 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 92 | fi 93 | rm -f "$RESOURCES_TO_COPY" 94 | 95 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 96 | then 97 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 98 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 99 | while read line; do 100 | if [[ $line != "${PODS_ROOT}*" ]]; then 101 | XCASSET_FILES+=("$line") 102 | fi 103 | done <<<"$OTHER_XCASSETS" 104 | 105 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 106 | fi 107 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Target Support Files/Pods-JHPageMenuViewDemo/Pods-JHPageMenuViewDemo.debug.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/Masonry" 3 | LIBRARY_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/Masonry" 4 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/Masonry" 5 | OTHER_LDFLAGS = $(inherited) -ObjC -l"Masonry" -framework "Foundation" -framework "UIKit" 6 | PODS_BUILD_DIR = $BUILD_DIR 7 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | -------------------------------------------------------------------------------- /JHPageMenuViewDemo/Pods/Target Support Files/Pods-JHPageMenuViewDemo/Pods-JHPageMenuViewDemo.release.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/Masonry" 3 | LIBRARY_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/Masonry" 4 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/Masonry" 5 | OTHER_LDFLAGS = $(inherited) -ObjC -l"Masonry" -framework "Foundation" -framework "UIKit" 6 | PODS_BUILD_DIR = $BUILD_DIR 7 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 gaofengtan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

Welcome to JHPageMenuView 👋

2 | 3 | ## ✨ 实现思路 4 | 5 | ##### 1、我们所知的分页菜单 6 | - 京东 7 | 8 | ![京东发现页.gif](http://upload-images.jianshu.io/upload_images/1248713-37fea9637385132c.gif?imageMogr2/auto-orient/strip) 9 | 10 | - 天猫 11 | 12 | ![天猫国际页.gif](http://upload-images.jianshu.io/upload_images/1248713-1e7e5d083f9f9950.gif?imageMogr2/auto-orient/strip) 13 | 14 | 15 | ##### 2、```JHPageMenuView```拽写的初衷 16 | - 已有的开源组件有哪些? 17 | > 1、**[WMPageController](https://github.com/wangmchn/WMPageController)**:OC版本,菜单只支持纯文本,装饰只有内置的几种,自定义性太低,可用范围有限; 18 | 2、**[PageMenu](https://github.com/PageMenu/PageMenu)**:Swift版本,菜单也是只支持纯文本,装饰器只有两种,自定义性太低,可用范围有限; 19 | 3、**[ZJScrollPageView](https://github.com/jasnig/ZJScrollPageView)**:OC版本,菜单支持文本和图片混合,装饰器只有内置的几种样式,自定义性太低,但大部分都够用; 20 | - 为什么做这个组件? 21 | >目前开源的组件无法满足快速变化的需求,UI层面永远是计划赶不上变化,不可能做到未雨绸缪;基于此,可能每个开发者到项目中都会根据当前的UI来重写一个。这样可能会出现一些重复的bug,重要的是浪费时间和精力。 22 | - 这个组件的优势是什么? 23 | >上面已经提到了目前开源组件无法实现UI层面的快速变化,所以这个组件的优势,就是能够以不变应万变。这个组件的UI支持高度自定义,但是接口并没有因此而变得复杂。 24 | - 这个组件源代码复杂吗? 25 | >可能你会想,高度自定义的UI组件,内部一定封装了很多东西来自动化。其实并没有你想的那么复杂,这个组件的内部只使用了一个```UICollectionView```和一个```UIScrollView```来实现功能,可以说是完全使用```UIKit```内置的UI组件,并没有过多复杂的代码。 26 | ##### 3、UI分析 27 | 28 | ![UI结构.png](http://upload-images.jianshu.io/upload_images/1248713-15f51f5078ff4fbd.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 29 | 30 | ##### 4、项目结构 31 | 32 | ![项目结构.png](http://upload-images.jianshu.io/upload_images/1248713-929220cbe1b6198d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 33 | 34 | ##### 5、滚动同步 35 | 菜单视图滚动会触发装饰视图滚动,以此达到滚动同步的目的 36 | 37 | ![滚动同步.gif](http://upload-images.jianshu.io/upload_images/1248713-1621cf2e68989eb6.gif?imageMogr2/auto-orient/strip) 38 | 39 | ``` 40 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView { 41 | // 菜单视图滚动的时候,装饰视图也要跟着一起滚动 42 | if (scrollView.tag == JHMENU_COLLECTION_VIEW_TAG) { 43 | [_decorateView.scrollView setContentOffset:scrollView.contentOffset]; 44 | } 45 | } 46 | ``` 47 | ##### 6、支持内置菜单样式+自定义菜单 48 | - **内置菜单**:组件目前内置的菜单样式只有纯文本的,一些常用的需求基本就够用了,内置菜单样式想要展示选中和未选中的样式,可以通过下面两个block来进行设置: 49 | ``` 50 | JHPageMenuItem *item = [JHPageMenuItem menuView:menuView itemForIndex:index]; 51 | 52 | item.menuItemNormalStyleBlock = ^{ 53 | // 告知item正常情况下的样式 54 | }; 55 | 56 | item.menuItemSelectedStyleBlock = ^{ 57 | // 告知item选中时的样式 58 | }; 59 | ``` 60 | ![内置菜单.gif](http://upload-images.jianshu.io/upload_images/1248713-fe88e09a9e0c9fad.gif?imageMogr2/auto-orient/strip) 61 | - **自定义菜单**:自定义菜单才是最核心的,自定义菜单继承自```JHPageMenuItem```基类(```JHPageMenuItem```其实就是继承自```UICollectionViewCell```),并且,需要重写下面两个方法: 62 | ``` 63 | @interface CustomMenuItem () 64 | @property (weak, nonatomic) IBOutlet UIView *markView; 65 | @end 66 | 67 | - (void)menuItemSelectedStyle { 68 | // 告知item正常情况下的样式,自定义的菜单需要重写该方法 69 | } 70 | 71 | - (void)menuItemNormalStyle { 72 | // 告知item选中时的样式,自定义的菜单需要重写该方法 73 | } 74 | 75 | @end 76 | ``` 77 | ![自定义菜单.gif](http://upload-images.jianshu.io/upload_images/1248713-53db4b5f3b6e6203.gif?imageMogr2/auto-orient/strip) 78 | 79 | ##### 7、支持内置装饰器+自定义装饰器 80 | - **内置装饰器**:菜单有内置的4中装饰器,基本涵盖了目前一些常用的样式; 81 | ``` 82 | /** 83 | 菜单装饰的自带样式 84 | */ 85 | typedef NS_ENUM(NSInteger, JHPageDecorateStyle) { 86 | JHPageDecorateStyleDefault, // 默认样式 87 | JHPageDecorateStyleLine, // 带下划线 88 | JHPageDecorateStyleFlood, // 涌入效果 (填充) 89 | JHPageDecorateStyleFloodHollow // 涌入效果 (空心的) 90 | }; 91 | ``` 92 | ![内置样式-JHPageDecorateStyleDefault.gif](http://upload-images.jianshu.io/upload_images/1248713-fe88e09a9e0c9fad.gif?imageMogr2/auto-orient/strip) 93 | 94 | ![内置样式-JHPageDecorateStyleLine.gif](http://upload-images.jianshu.io/upload_images/1248713-e80a6f8a7e61f1df.gif?imageMogr2/auto-orient/strip) 95 | 96 | ![内置样式-JHPageDecorateStyleFlood.gif](http://upload-images.jianshu.io/upload_images/1248713-0f8ab4a5e10e36b2.gif?imageMogr2/auto-orient/strip) 97 | 98 | ![内置样式-JHPageDecorateStyleFloodHollow.gif](http://upload-images.jianshu.io/upload_images/1248713-76128daebb74b121.gif?imageMogr2/auto-orient/strip) 99 | 100 | - **自定义装饰器**:难免会有与众不同的UI,这个时候自定义装饰器就可以大显神通了,很简单,你只要实现一个数据源代理方法,把你想要的装饰器设置进去,就OK了 101 | ``` 102 | - (UIView *)decorateItemInMenuView:(JHPageMenuView *)menuView { 103 | // 在这里设置你的自定义装饰器 104 | } 105 | ``` 106 | ![自定义装饰器.gif](http://upload-images.jianshu.io/upload_images/1248713-b71f248d2a23c24f.gif?imageMogr2/auto-orient/strip) 107 | 108 | ##### 8、菜单切换可嵌入自定义动画 109 | 菜单切换默认是没有动画的,不过已经提供了接口 110 | - 内置菜单切换动画,可以通过下面提供的block来实现: 111 | ``` 112 | item.menuItemNormalStyleAnimationBlock = ^{ 113 | // 告知item 从 选中 - 未选中 时执行的动画,可以通过这个block进行设置 114 | }; 115 | 116 | item.menuItemSelectedStyleAnimationBlock = ^{ 117 | // 告知item 从 未选中 - 选中 时执行的动画,可以通过这个block进行设置 118 | }; 119 | ``` 120 | - 自定义菜单切换动画,可以重写下面两个方法 121 | ``` 122 | - (void)menuItemNormalStyleAnimation { 123 | // 告知item 从 选中 - 未选中 时执行的动画,自定义的菜单如果需要执行动画,需要重写该方法 124 | } 125 | 126 | - (void)menuItemSelectedStyleAnimation { 127 | // 告知item 从 未选中 - 选中 时执行的动画,自定义的菜单如果需要执行动画,需要重写该方法 128 | } 129 | ``` 130 | 131 | ##### 9、菜单支持垂直和水平的滚动方向 132 | 菜单支持横向和竖向的滚动,可用范围更广 133 | ``` 134 | /** 135 | 菜单滚动方向 136 | */ 137 | typedef NS_ENUM(NSInteger, JHPageMenuScrollDirection) { 138 | JHPageMenuScrollDirectionHorizontal, // 水平 139 | JHPageMenuScrollDirectionVertical // 垂直 140 | }; 141 | ``` 142 | ![水平滚动的菜单.gif](http://upload-images.jianshu.io/upload_images/1248713-e80a6f8a7e61f1df.gif?imageMogr2/auto-orient/strip) 143 | 144 | ![垂直滚动的菜单.gif](http://upload-images.jianshu.io/upload_images/1248713-c43b909aaac8f4c1.gif?imageMogr2/auto-orient/strip) 145 | 146 | ##### 10、JHPageController 147 | ```JHPageController```是基于```JHPageMenuVeiw```和```UIPageViewController```进行封装的一个分页控制器,控制器内部已经把这两个组件的关联进行了封装,并且暴露了代理出来,只需要简单的几行代码,就能实现一个炫酷的分页控制器,依赖于```JHPageMenuVeiw```高度可自定义功能,```JHPageController```的功能依旧强大。 148 | 149 | ![项目结构.png](http://upload-images.jianshu.io/upload_images/1248713-8d0916dd5b34687b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 150 | 151 | 152 | ![JHPageController展示-顶部.gif](http://upload-images.jianshu.io/upload_images/1248713-bc22c9d614db47dc.gif?imageMogr2/auto-orient/strip) 153 | 154 | ![JHPageController展示-左边.gif](http://upload-images.jianshu.io/upload_images/1248713-422643a5f4ef1013.gif?imageMogr2/auto-orient/strip) 155 | 156 | ![JHPageController展示-底部.gif](http://upload-images.jianshu.io/upload_images/1248713-a5111347ef9dc9b8.gif?imageMogr2/auto-orient/strip) 157 | 158 | ![JHPageController展示-右边.gif](http://upload-images.jianshu.io/upload_images/1248713-b596cb59216d2f56.gif?imageMogr2/auto-orient/strip) 159 | 160 | ![JHPageController展示-导航栏.gif](http://upload-images.jianshu.io/upload_images/1248713-ef9006d970218357.gif?imageMogr2/auto-orient/strip) 161 | 162 | ##### 11、遇到的问题 163 | - 如何简单的实现装饰器视图 164 | >一开始是有尝试用```UICollectionView```来承载装饰器的,直接用iOS9的新特性,对单元格进行重排来实现移动动画,因为是内置的动画,而且```UICollectionView```已经是比较成熟的集合视图,所以才会有这个想法。但后来经过尝试发现还是存在不少未知问题,所以就放弃了,改用```UIScollView```来封装一个装饰器视图。 165 | - UIScrollView的滚动和View的移动动画同时进行导致的卡顿 166 | >导致这种现象的原因就是```runloop```在作怪;解决办法就是启动一个定时器,把定时器添加到```NSRunLoopCommonModes```的mode下,然后在这个定时器下定时移动View,达到一种动画的效果。 167 | - CADisplayLink定时器替代NSTimer定时器([关于CADisplayLink](http://www.jianshu.com/p/c35a81c3b9eb)) 168 | >```CADisplayLink``` 是一个能让我们以和屏幕刷新率相同的频率将内容画到屏幕上的定时器,精确度相当高。一但 ```CADisplayLink``` 以特定的模式注册到```runloop```之后,每当屏幕需要刷新的时候,```runloop```就会调用```CADisplayLink```绑定的```target```上的```selector```。至此,动画卡顿问题解决。 169 | --------------------------------------------------------------------------------