├── .gitignore ├── LICENSE ├── README.md ├── YZPullDownMenu.podspec ├── YZPullDownMenu ├── YZCover.h ├── YZCover.m ├── YZPullDownMenu.h └── YZPullDownMenu.m └── YZPullDownMenuDemo ├── YZPullDownMenuDemo.xcodeproj ├── project.pbxproj └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── yuanzheng.xcuserdatad │ └── UserInterfaceState.xcuserstate └── YZPullDownMenuDemo ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets ├── AppIcon.appiconset │ └── Contents.json └── NewSearch │ ├── Contents.json │ ├── 搜索-更多-已选中.imageset │ ├── Contents.json │ ├── 搜索-更多-已选中@2x.png │ └── 搜索-更多-已选中@3x.png │ ├── 搜索-更多-未选中.imageset │ ├── Contents.json │ ├── 搜索-更多-未选中@2x.png │ └── 搜索-更多-未选中@3x.png │ ├── 标签-向上箭头.imageset │ ├── Contents.json │ ├── 标签-向上箭头@2x.png │ └── 标签-向上箭头@3x.png │ ├── 标签-向下箭头.imageset │ ├── Contents.json │ ├── 标签-向下箭头@2x.png │ └── 标签-向下箭头@3x.png │ └── 选中对号.imageset │ ├── Contents.json │ ├── 选中对号@2x.png │ └── 选中对号@3x.png ├── Base.lproj ├── LaunchScreen.storyboard └── Main.storyboard ├── Classes ├── AllCourse │ └── Controllers │ │ ├── YZAllCourseViewController.h │ │ ├── YZAllCourseViewController.m │ │ └── YZAllCourseViewController.xib ├── MoreMenu │ ├── Controllers │ │ ├── YZMoreMenuViewController.h │ │ ├── YZMoreMenuViewController.m │ │ └── YZMoreMenuViewController.xib │ └── Views │ │ ├── YZMoreMenuCell.h │ │ └── YZMoreMenuCell.m ├── Other │ ├── UIView+YZCategory.h │ ├── UIView+YZCategory.m │ ├── YZMenuButton.h │ └── YZMenuButton.m └── Sort │ ├── Controllers │ ├── YZSortViewController.h │ └── YZSortViewController.m │ └── Views │ ├── YZSortCell.h │ ├── YZSortCell.m │ └── YZSortCell.xib ├── Info.plist ├── ViewController.h ├── ViewController.m └── main.m /.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 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 29 | 30 | # CocoaPods 31 | # 32 | # We recommend against adding the Pods directory to your .gitignore. However 33 | # you should judge for yourself, the pros and cons are mentioned at: 34 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 35 | # 36 | # Pods/ 37 | 38 | # Carthage 39 | # 40 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 41 | # Carthage/Checkouts 42 | 43 | Carthage/Build 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 51 | 52 | fastlane/report.xml 53 | fastlane/screenshots 54 | 55 | #Code Injection 56 | # 57 | # After new code Injection tools there's a generated folder /iOSInjectionProject 58 | # https://github.com/johnno1962/injectionforxcode 59 | 60 | iOSInjectionProject/ 61 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 iThinker_YZ 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 | # YZPullDownMenuDemo 2 | 快速继承搜索界面下拉菜单 3 | # 支持cocoapods 4 | 5 | ## 详情请参考简书 6 | http://www.jianshu.com/p/0e1bb29be42e 7 | -------------------------------------------------------------------------------- /YZPullDownMenu.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod spec lint YZPullDownMenu.podspec' to ensure this is a 3 | # valid spec and to remove all comments including this before submitting the spec. 4 | # 5 | # To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html 6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | 11 | 12 | s.name = "YZPullDownMenu" 13 | s.version = "1.0" 14 | s.summary = "Title Bar Gradient with the User to drag for ios." 15 | s.homepage = "https://github.com/iThinkerYZ" 16 | s.license = "MIT" 17 | s.author = { "iThinkerYZ" => "690423479@qq.com" } 18 | s.platform = :ios, "7.0" 19 | s.source = { :git => "https://github.com/iThinkerYZ/YZPullDownMenuDemo.git", :tag => "1.0" } 20 | 21 | s.source_files = "YZPullDownMenu/*.{h,m}" 22 | 23 | s.framework = "UIKit" 24 | 25 | 26 | 27 | end 28 | -------------------------------------------------------------------------------- /YZPullDownMenu/YZCover.h: -------------------------------------------------------------------------------- 1 | // 2 | // YZCover.h 3 | // PullDownMenu 4 | // 5 | // Created by yz on 16/8/12. 6 | // Copyright © 2016年 yz. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface YZCover : UIView 12 | /** 13 | * 点击蒙版调用 14 | */ 15 | @property (nonatomic, strong) void(^clickCover)(); 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /YZPullDownMenu/YZCover.m: -------------------------------------------------------------------------------- 1 | // 2 | // YZCover.m 3 | // PullDownMenu 4 | // 5 | // Created by yz on 16/8/12. 6 | // Copyright © 2016年 yz. All rights reserved. 7 | // 8 | 9 | #import "YZCover.h" 10 | 11 | @implementation YZCover 12 | 13 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 14 | { 15 | if (_clickCover) { 16 | _clickCover(); 17 | } 18 | } 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /YZPullDownMenu/YZPullDownMenu.h: -------------------------------------------------------------------------------- 1 | // 2 | // PullDownMenu.h 3 | // PullDownMenu 4 | // 5 | // Created by yz on 16/8/12. 6 | // Copyright © 2016年 yz. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class YZPullDownItem,YZPullDownMenu; 12 | 13 | /** 14 | * 下拉菜单数据源协议 15 | */ 16 | @protocol YZPullDownMenuDataSource 17 | 18 | /** 19 | * 下拉菜单有多少列 20 | * 21 | * @param pullDownMenu 下拉菜单 22 | * 23 | * @return 下拉菜单有多少列 24 | */ 25 | - (NSInteger)numberOfColsInMenu:(YZPullDownMenu *)pullDownMenu; 26 | 27 | /** 28 | * 下拉菜单每列按钮外观 29 | * 30 | * @param pullDownMenu 下拉菜单 31 | * @param index 第几列 32 | * 33 | * @return 下拉菜单每列按钮外观 34 | */ 35 | - (UIButton *)pullDownMenu:(YZPullDownMenu *)pullDownMenu buttonForColAtIndex:(NSInteger)index; 36 | 37 | /** 38 | * 下拉菜单每列对应的控制器 39 | * 40 | * @param pullDownMenu 下拉菜单 41 | * @param index 第几列 42 | * 43 | * @return 下拉菜单每列对应的控制器 44 | */ 45 | - (UIViewController *)pullDownMenu:(YZPullDownMenu *)pullDownMenu viewControllerForColAtIndex:(NSInteger)index; 46 | 47 | /** 48 | * 下拉菜单每列对应的高度 49 | * 50 | * @param pullDownMenu 下拉菜单 51 | * @param index 第几列 52 | * 53 | * @return 下拉菜单每列对应的高度 54 | */ 55 | - (CGFloat)pullDownMenu:(YZPullDownMenu *)pullDownMenu heightForColAtIndex:(NSInteger)index; 56 | 57 | @end 58 | 59 | 60 | /** 61 | * 更新菜单标题,就发送这个通知(YZUpdateMenuTitleNote) 62 | 为了降低耦合,才采取这种方式,而且方便通知主要界面,刷新数据、 63 | 64 | *** 【更新菜单标题步骤】 *** 65 | 1.把 【extern NSString * const YZUpdateMenuTitleNote;】 拷贝到自己控制器中 66 | 67 | 2.在选中标题的方法中,发送以下通知 68 | [[NSNotificationCenter defaultCenter] postNotificationName:YZUpdateMenuTitleNote object:self userInfo:@{@"title":cell.textLabel.text}]; 69 | 70 | 3.1 postNotificationName:通知名称 =>【YZUpdateMenuTitleNote】 71 | 72 | 3.2 object:谁发送的通知 =>【self】(当前控制器) 73 | 74 | 3.3 userInfo:选中标题信息 => 可以多个key,多个value,没有固定的,因为有些界面,需要勾选很多选项,key可以随意定义。 75 | 76 | 3.4 底层会自动判定,当前userInfo有多少个value,如果有一个就会直接更新菜单标题,有多个就会更新,满足大部分需求。 77 | 78 | 3.5 发出通知,会自动弹回下拉菜单 79 | 80 | */ 81 | extern NSString * const YZUpdateMenuTitleNote; 82 | 83 | @interface YZPullDownMenu : UIView 84 | /** 85 | * 下拉菜单数据源 86 | */ 87 | @property (nonatomic, weak) id dataSource; 88 | /** 89 | * 分割线颜色 90 | */ 91 | @property (nonatomic, strong) UIColor *separateLineColor; 92 | /** 93 | * 分割线距离顶部间距,默认10 94 | */ 95 | @property (nonatomic, assign) NSInteger separateLineTopMargin; 96 | /** 97 | * 蒙版颜色 98 | */ 99 | @property (nonatomic, strong) UIColor *coverColor; 100 | 101 | /** 102 | * 刷新下拉菜单 103 | */ 104 | - (void)reload; 105 | @end 106 | -------------------------------------------------------------------------------- /YZPullDownMenu/YZPullDownMenu.m: -------------------------------------------------------------------------------- 1 | // 2 | // PullDownMenu.m 3 | // PullDownMenu 4 | // 5 | // Created by yz on 16/8/12. 6 | // Copyright © 2016年 yz. All rights reserved. 7 | // 8 | 9 | #import "YZPullDownMenu.h" 10 | #import "YZCover.h" 11 | 12 | // 更新下拉菜单标题通知名称 13 | NSString * const YZUpdateMenuTitleNote = @"YZUpdateMenuTitleNote"; 14 | 15 | @interface YZPullDownMenu () 16 | /** 17 | * 下拉菜单所有按钮 18 | */ 19 | @property (nonatomic, strong) NSMutableArray *menuButtons; 20 | /** 21 | * 下拉菜单所有分割线 22 | */ 23 | @property (nonatomic, strong) NSMutableArray *separateLines; 24 | /** 25 | * 下拉菜单所有控制器 26 | */ 27 | @property (nonatomic, strong) NSMutableArray *controllers; 28 | /** 29 | * 下拉菜单每列高度 30 | */ 31 | @property (nonatomic, strong) NSMutableArray *colsHeight; 32 | /** 33 | * 下拉菜单内容View 34 | */ 35 | @property (nonatomic, strong) UIView *contentView; 36 | /** 37 | * 下拉菜单蒙版 38 | */ 39 | @property (nonatomic, strong) YZCover *coverView; 40 | /** 41 | * 下拉菜单底部View 42 | */ 43 | @property (nonatomic, weak) UIView *bottomLine; 44 | /** 45 | * 观察者 46 | */ 47 | @property (nonatomic, weak) id observer; 48 | @end 49 | 50 | @implementation YZPullDownMenu 51 | 52 | #pragma mark - 懒加载 53 | - (NSMutableArray *)separateLines 54 | { 55 | if (_separateLines == nil) { 56 | _separateLines = [NSMutableArray array]; 57 | } 58 | return _separateLines; 59 | } 60 | 61 | - (NSMutableArray *)menuButtons 62 | { 63 | if (_menuButtons == nil) { 64 | _menuButtons = [NSMutableArray array]; 65 | } 66 | return _menuButtons; 67 | } 68 | 69 | - (NSMutableArray *)colsHeight 70 | { 71 | if (_colsHeight == nil) { 72 | _colsHeight = [NSMutableArray array]; 73 | } 74 | return _colsHeight; 75 | } 76 | 77 | - (NSMutableArray *)controllers 78 | { 79 | if (_controllers == nil) { 80 | _controllers = [NSMutableArray array]; 81 | } 82 | return _controllers; 83 | } 84 | 85 | - (UIView *)coverView 86 | { 87 | if (_coverView == nil) { 88 | 89 | // 设置蒙版的frame 90 | CGFloat coverX = 0; 91 | CGFloat coverY = CGRectGetMaxY(self.frame); 92 | CGFloat coverW = self.frame.size.width; 93 | CGFloat coverH = self.superview.bounds.size.height - coverY; 94 | _coverView = [[YZCover alloc] initWithFrame:CGRectMake(coverX, coverY, coverW, coverH)]; 95 | _coverView.backgroundColor = _coverColor; 96 | [self.superview addSubview:_coverView]; 97 | 98 | // Cover 的 Block 99 | __weak typeof(self) weakSelf = self; 100 | _coverView.clickCover = ^{ // 点击蒙版调用 101 | [weakSelf dismiss]; 102 | }; 103 | } 104 | return _coverView; 105 | } 106 | 107 | - (UIView *)contentView 108 | { 109 | if (_contentView == nil) { 110 | _contentView = [[UIView alloc] init]; 111 | _contentView.backgroundColor = [UIColor whiteColor]; 112 | _contentView.frame = CGRectMake(0, 0, self.bounds.size.width, 0); 113 | _contentView.clipsToBounds = YES; 114 | [self.coverView addSubview:_contentView]; 115 | } 116 | return _contentView; 117 | } 118 | 119 | #pragma mark - 初始化 120 | - (instancetype)initWithFrame:(CGRect)frame{ 121 | if (self = [super initWithFrame:frame]) { 122 | [self setup]; 123 | } 124 | return self; 125 | } 126 | 127 | // 初始化控件 128 | - (void)setup 129 | { 130 | self.backgroundColor = [UIColor whiteColor]; 131 | 132 | _separateLineTopMargin = 10; 133 | 134 | _separateLineColor = [UIColor colorWithRed:221 / 255.0 green:221 / 255.0 blue:221 / 255.0 alpha:1]; 135 | 136 | _coverColor = [UIColor colorWithRed:221 / 255.0 green:221 / 255.0 blue:221 / 255.0 alpha:.7]; 137 | 138 | // 监听更新菜单标题通知 139 | _observer = [[NSNotificationCenter defaultCenter] addObserverForName:YZUpdateMenuTitleNote object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) { 140 | 141 | // 获取列 142 | NSInteger col = [self.controllers indexOfObject:note.object]; 143 | 144 | // 获取对应按钮 145 | UIButton *btn = self.menuButtons[col]; 146 | 147 | // 隐藏下拉菜单 148 | [self dismiss]; 149 | 150 | // 获取所有值 151 | NSArray *allValues = note.userInfo.allValues; 152 | 153 | // 不需要设置标题,字典个数大于1,或者有数组 154 | if (allValues.count > 1 || [allValues.firstObject isKindOfClass:[NSArray class]]) return ; 155 | 156 | // 设置按钮标题 157 | [btn setTitle:allValues.firstObject forState:UIControlStateNormal]; 158 | 159 | }]; 160 | } 161 | 162 | #pragma mark - 布局子控件 163 | - (void)layoutSubviews 164 | { 165 | [super layoutSubviews]; 166 | 167 | // 布局子控件 168 | NSInteger count = self.menuButtons.count; 169 | 170 | CGFloat btnX = 0; 171 | CGFloat btnY = 0; 172 | CGFloat btnW = self.bounds.size.width / count; 173 | CGFloat btnH = self.bounds.size.height; 174 | 175 | for (NSInteger i = 0; i < count; i++) { 176 | // 设置按钮位置 177 | UIButton *btn = self.menuButtons[i]; 178 | btnX = i * btnW; 179 | btn.frame = CGRectMake(btnX, btnY, btnW, btnH); 180 | 181 | // 设置分割线位置 182 | if (i < count - 1) { 183 | UIView *separateLine = self.separateLines[i]; 184 | separateLine.frame = CGRectMake(CGRectGetMaxX(btn.frame), _separateLineTopMargin, 1, btnH - 2 * _separateLineTopMargin); 185 | } 186 | } 187 | 188 | // 设置底部View位置 189 | CGFloat bottomH = 1; 190 | CGFloat bottomY = btnH - bottomH; 191 | _bottomLine.frame = CGRectMake(0, bottomY, self.bounds.size.width, bottomH); 192 | } 193 | 194 | #pragma mark - 即将进入窗口 195 | - (void)willMoveToWindow:(UIWindow *)newWindow 196 | { 197 | [super willMoveToWindow:newWindow]; 198 | 199 | [self reload]; 200 | } 201 | 202 | #pragma mark - 下拉菜单功能 203 | // 删除之前所有数据,移除之前所有子控件 204 | - (void)clear 205 | { 206 | self.bottomLine = nil; 207 | self.coverView = nil; 208 | self.contentView = nil; 209 | [self.separateLines removeAllObjects]; 210 | [self.menuButtons removeAllObjects]; 211 | [self.controllers removeAllObjects]; 212 | [self.colsHeight removeAllObjects]; 213 | [self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)]; 214 | } 215 | 216 | // 刷新下拉菜单 217 | - (void)reload 218 | { 219 | // 删除之前所有数据,移除之前所有子控件 220 | [self clear]; 221 | 222 | // 没有数据源,直接返回 223 | if (self.dataSource == nil) return; 224 | 225 | // 判断之前是否添加过,添加过就不添加了 226 | if (self.menuButtons.count) return; 227 | 228 | 229 | // 判断有没有实现numberOfColsInMenu: 230 | if (![self.dataSource respondsToSelector:@selector(numberOfColsInMenu:)]) { 231 | @throw [NSException exceptionWithName:@"YZError" reason:@"未实现(numberOfColsInMenu:)" userInfo:nil]; 232 | } 233 | 234 | // 判断有没有实现pullDownMenu:buttonForColAtIndex: 235 | if (![self.dataSource respondsToSelector:@selector(pullDownMenu:buttonForColAtIndex:)]) { 236 | @throw [NSException exceptionWithName:@"YZError" reason:@"pullDownMenu:buttonForColAtIndex:)" userInfo:nil]; 237 | } 238 | 239 | // 判断每一列控制器的方法是否实现 240 | if (![self.dataSource respondsToSelector:@selector(pullDownMenu:viewControllerForColAtIndex:)]) { 241 | @throw [NSException exceptionWithName:@"YZError" reason:@"pullDownMenu:viewControllerForColAtIndex:这个方法未实现)" userInfo:nil]; 242 | return; 243 | } 244 | 245 | // 判断每一列控制器的方法是否实现 246 | if (![self.dataSource respondsToSelector:@selector(pullDownMenu:heightForColAtIndex:)]) { 247 | @throw [NSException exceptionWithName:@"YZError" reason:@"pullDownMenu:heightForColAtIndex:这个方法未实现)" userInfo:nil]; 248 | return; 249 | } 250 | 251 | // 获取有多少列 252 | NSInteger cols = [self.dataSource numberOfColsInMenu:self]; 253 | 254 | // 没有列直接返回 255 | if (cols == 0) return; 256 | 257 | // 添加按钮 258 | for (NSInteger col = 0; col < cols; col++) { 259 | 260 | // 获取按钮 261 | UIButton *menuButton = [self.dataSource pullDownMenu:self buttonForColAtIndex:col]; 262 | 263 | menuButton.tag = col; 264 | 265 | [menuButton addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside]; 266 | 267 | if (menuButton == nil) { 268 | @throw [NSException exceptionWithName:@"YZError" reason:@"pullDownMenu:buttonForColAtIndex:这个方法不能返回空的按钮)" userInfo:nil]; 269 | return; 270 | } 271 | 272 | [self addSubview:menuButton]; 273 | 274 | // 添加按钮 275 | [self.menuButtons addObject:menuButton]; 276 | 277 | // 保存所有列的高度 278 | CGFloat height = [self.dataSource pullDownMenu:self heightForColAtIndex:col]; 279 | [self.colsHeight addObject:@(height)]; 280 | 281 | // 保存所有子控制器 282 | UIViewController *vc = [self.dataSource pullDownMenu:self viewControllerForColAtIndex:col]; 283 | [self.controllers addObject:vc]; 284 | } 285 | 286 | // 添加分割线 287 | NSInteger count = cols - 1; 288 | for (NSInteger i = 0; i < count; i++) { 289 | UIView *separateLine = [[UIView alloc] init]; 290 | separateLine.backgroundColor = _separateLineColor; 291 | [self addSubview:separateLine]; 292 | [self.separateLines addObject:separateLine]; 293 | } 294 | 295 | // 添加底部View 296 | UIView *bottomView = [[UIView alloc] init]; 297 | bottomView.backgroundColor = _separateLineColor; 298 | _bottomLine = bottomView; 299 | [self addSubview:bottomView]; 300 | 301 | // 设置所有子控件的尺寸 302 | [self layoutSubviews]; 303 | 304 | } 305 | 306 | #pragma mark - 下拉菜单弹回 307 | - (void)dismiss 308 | { 309 | // 所有按钮取消选中 310 | for (UIButton *button in self.menuButtons) { 311 | button.selected = NO; 312 | } 313 | 314 | // 移除蒙版 315 | self.coverView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0]; 316 | 317 | [UIView animateWithDuration:0.25 animations:^{ 318 | 319 | CGRect frame = self.contentView.frame; 320 | frame.size.height = 0; 321 | self.contentView.frame = frame; 322 | 323 | } completion:^(BOOL finished) { 324 | 325 | self.coverView.hidden = YES; 326 | 327 | self.coverView.backgroundColor = _coverColor; 328 | 329 | }]; 330 | } 331 | 332 | 333 | #pragma mark - 点击菜单标题按钮 334 | - (void)btnClick:(UIButton *)button 335 | { 336 | button.selected = !button.selected; 337 | 338 | // 取消其他按钮选中 339 | for (UIButton *otherButton in self.menuButtons) { 340 | if (otherButton == button) continue; 341 | otherButton.selected = NO; 342 | } 343 | 344 | if (button.selected == YES) { // 当按钮选中,弹出蒙版 345 | // 添加对应蒙版 346 | self.coverView.hidden = NO; 347 | 348 | // 获取角标 349 | NSInteger i = button.tag; 350 | 351 | // 移除之前子控制器的View 352 | [self.contentView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)]; 353 | 354 | // 添加对应子控制器的view 355 | UIViewController *vc = self.controllers[i]; 356 | vc.view.frame = self.contentView.bounds; 357 | [self.contentView addSubview:vc.view]; 358 | 359 | // 设置内容的高度 360 | CGFloat height = [self.colsHeight[i] floatValue]; 361 | 362 | [UIView animateWithDuration:0.25 animations:^{ 363 | 364 | CGRect frame = self.contentView.frame; 365 | frame.size.height = height; 366 | self.contentView.frame = frame; 367 | } ]; 368 | } else { // 当按钮未选中,收回蒙版 369 | [self dismiss]; 370 | } 371 | } 372 | 373 | #pragma mark - 界面销毁 374 | - (void)dealloc 375 | { 376 | [self clear]; 377 | 378 | [[NSNotificationCenter defaultCenter] removeObserver:_observer]; 379 | } 380 | 381 | @end 382 | -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | ECDD40131D5EF2EC00EB3C85 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = ECDD40121D5EF2EC00EB3C85 /* main.m */; }; 11 | ECDD40161D5EF2EC00EB3C85 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = ECDD40151D5EF2EC00EB3C85 /* AppDelegate.m */; }; 12 | ECDD40191D5EF2EC00EB3C85 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = ECDD40181D5EF2EC00EB3C85 /* ViewController.m */; }; 13 | ECDD401C1D5EF2EC00EB3C85 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = ECDD401A1D5EF2EC00EB3C85 /* Main.storyboard */; }; 14 | ECDD401E1D5EF2EC00EB3C85 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = ECDD401D1D5EF2EC00EB3C85 /* Assets.xcassets */; }; 15 | ECDD40211D5EF2EC00EB3C85 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = ECDD401F1D5EF2EC00EB3C85 /* LaunchScreen.storyboard */; }; 16 | ECDD40701D5EF3FA00EB3C85 /* YZAllCourseViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = ECDD40551D5EF3FA00EB3C85 /* YZAllCourseViewController.m */; }; 17 | ECDD40711D5EF3FA00EB3C85 /* YZAllCourseViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = ECDD40561D5EF3FA00EB3C85 /* YZAllCourseViewController.xib */; }; 18 | ECDD40721D5EF3FA00EB3C85 /* YZMoreMenuViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = ECDD405C1D5EF3FA00EB3C85 /* YZMoreMenuViewController.m */; }; 19 | ECDD40731D5EF3FA00EB3C85 /* YZMoreMenuViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = ECDD405D1D5EF3FA00EB3C85 /* YZMoreMenuViewController.xib */; }; 20 | ECDD40741D5EF3FA00EB3C85 /* YZMoreMenuCell.m in Sources */ = {isa = PBXBuildFile; fileRef = ECDD40611D5EF3FA00EB3C85 /* YZMoreMenuCell.m */; }; 21 | ECDD40751D5EF3FA00EB3C85 /* UIView+YZCategory.m in Sources */ = {isa = PBXBuildFile; fileRef = ECDD40641D5EF3FA00EB3C85 /* UIView+YZCategory.m */; }; 22 | ECDD40761D5EF3FA00EB3C85 /* YZMenuButton.m in Sources */ = {isa = PBXBuildFile; fileRef = ECDD40661D5EF3FA00EB3C85 /* YZMenuButton.m */; }; 23 | ECDD40771D5EF3FA00EB3C85 /* YZSortViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = ECDD406A1D5EF3FA00EB3C85 /* YZSortViewController.m */; }; 24 | ECDD40781D5EF3FA00EB3C85 /* YZSortCell.m in Sources */ = {isa = PBXBuildFile; fileRef = ECDD406E1D5EF3FA00EB3C85 /* YZSortCell.m */; }; 25 | ECDD40791D5EF3FA00EB3C85 /* YZSortCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = ECDD406F1D5EF3FA00EB3C85 /* YZSortCell.xib */; }; 26 | ECDD40861D5EF7BE00EB3C85 /* YZCover.m in Sources */ = {isa = PBXBuildFile; fileRef = ECDD40831D5EF7BE00EB3C85 /* YZCover.m */; }; 27 | ECDD40871D5EF7BE00EB3C85 /* YZPullDownMenu.m in Sources */ = {isa = PBXBuildFile; fileRef = ECDD40851D5EF7BE00EB3C85 /* YZPullDownMenu.m */; }; 28 | /* End PBXBuildFile section */ 29 | 30 | /* Begin PBXFileReference section */ 31 | ECDD400E1D5EF2EC00EB3C85 /* YZPullDownMenuDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = YZPullDownMenuDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 32 | ECDD40121D5EF2EC00EB3C85 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 33 | ECDD40141D5EF2EC00EB3C85 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 34 | ECDD40151D5EF2EC00EB3C85 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 35 | ECDD40171D5EF2EC00EB3C85 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 36 | ECDD40181D5EF2EC00EB3C85 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 37 | ECDD401B1D5EF2EC00EB3C85 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 38 | ECDD401D1D5EF2EC00EB3C85 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 39 | ECDD40201D5EF2EC00EB3C85 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 40 | ECDD40221D5EF2EC00EB3C85 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 41 | ECDD40541D5EF3FA00EB3C85 /* YZAllCourseViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YZAllCourseViewController.h; sourceTree = ""; }; 42 | ECDD40551D5EF3FA00EB3C85 /* YZAllCourseViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YZAllCourseViewController.m; sourceTree = ""; }; 43 | ECDD40561D5EF3FA00EB3C85 /* YZAllCourseViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = YZAllCourseViewController.xib; sourceTree = ""; }; 44 | ECDD405B1D5EF3FA00EB3C85 /* YZMoreMenuViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YZMoreMenuViewController.h; sourceTree = ""; }; 45 | ECDD405C1D5EF3FA00EB3C85 /* YZMoreMenuViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YZMoreMenuViewController.m; sourceTree = ""; }; 46 | ECDD405D1D5EF3FA00EB3C85 /* YZMoreMenuViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = YZMoreMenuViewController.xib; sourceTree = ""; }; 47 | ECDD40601D5EF3FA00EB3C85 /* YZMoreMenuCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YZMoreMenuCell.h; sourceTree = ""; }; 48 | ECDD40611D5EF3FA00EB3C85 /* YZMoreMenuCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YZMoreMenuCell.m; sourceTree = ""; }; 49 | ECDD40631D5EF3FA00EB3C85 /* UIView+YZCategory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+YZCategory.h"; sourceTree = ""; }; 50 | ECDD40641D5EF3FA00EB3C85 /* UIView+YZCategory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+YZCategory.m"; sourceTree = ""; }; 51 | ECDD40651D5EF3FA00EB3C85 /* YZMenuButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YZMenuButton.h; sourceTree = ""; }; 52 | ECDD40661D5EF3FA00EB3C85 /* YZMenuButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YZMenuButton.m; sourceTree = ""; }; 53 | ECDD40691D5EF3FA00EB3C85 /* YZSortViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YZSortViewController.h; sourceTree = ""; }; 54 | ECDD406A1D5EF3FA00EB3C85 /* YZSortViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YZSortViewController.m; sourceTree = ""; }; 55 | ECDD406D1D5EF3FA00EB3C85 /* YZSortCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YZSortCell.h; sourceTree = ""; }; 56 | ECDD406E1D5EF3FA00EB3C85 /* YZSortCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YZSortCell.m; sourceTree = ""; }; 57 | ECDD406F1D5EF3FA00EB3C85 /* YZSortCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = YZSortCell.xib; sourceTree = ""; }; 58 | ECDD40821D5EF7BE00EB3C85 /* YZCover.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YZCover.h; sourceTree = ""; }; 59 | ECDD40831D5EF7BE00EB3C85 /* YZCover.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YZCover.m; sourceTree = ""; }; 60 | ECDD40841D5EF7BE00EB3C85 /* YZPullDownMenu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YZPullDownMenu.h; sourceTree = ""; }; 61 | ECDD40851D5EF7BE00EB3C85 /* YZPullDownMenu.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YZPullDownMenu.m; sourceTree = ""; }; 62 | /* End PBXFileReference section */ 63 | 64 | /* Begin PBXFrameworksBuildPhase section */ 65 | ECDD400B1D5EF2EC00EB3C85 /* Frameworks */ = { 66 | isa = PBXFrameworksBuildPhase; 67 | buildActionMask = 2147483647; 68 | files = ( 69 | ); 70 | runOnlyForDeploymentPostprocessing = 0; 71 | }; 72 | /* End PBXFrameworksBuildPhase section */ 73 | 74 | /* Begin PBXGroup section */ 75 | ECDD40051D5EF2EC00EB3C85 = { 76 | isa = PBXGroup; 77 | children = ( 78 | ECDD40101D5EF2EC00EB3C85 /* YZPullDownMenuDemo */, 79 | ECDD400F1D5EF2EC00EB3C85 /* Products */, 80 | ); 81 | sourceTree = ""; 82 | }; 83 | ECDD400F1D5EF2EC00EB3C85 /* Products */ = { 84 | isa = PBXGroup; 85 | children = ( 86 | ECDD400E1D5EF2EC00EB3C85 /* YZPullDownMenuDemo.app */, 87 | ); 88 | name = Products; 89 | sourceTree = ""; 90 | }; 91 | ECDD40101D5EF2EC00EB3C85 /* YZPullDownMenuDemo */ = { 92 | isa = PBXGroup; 93 | children = ( 94 | ECDD40811D5EF7BE00EB3C85 /* YZPullDownMenu */, 95 | ECDD40511D5EF3FA00EB3C85 /* Classes */, 96 | ECDD40141D5EF2EC00EB3C85 /* AppDelegate.h */, 97 | ECDD40151D5EF2EC00EB3C85 /* AppDelegate.m */, 98 | ECDD40171D5EF2EC00EB3C85 /* ViewController.h */, 99 | ECDD40181D5EF2EC00EB3C85 /* ViewController.m */, 100 | ECDD401A1D5EF2EC00EB3C85 /* Main.storyboard */, 101 | ECDD401D1D5EF2EC00EB3C85 /* Assets.xcassets */, 102 | ECDD401F1D5EF2EC00EB3C85 /* LaunchScreen.storyboard */, 103 | ECDD40221D5EF2EC00EB3C85 /* Info.plist */, 104 | ECDD40111D5EF2EC00EB3C85 /* Supporting Files */, 105 | ); 106 | path = YZPullDownMenuDemo; 107 | sourceTree = ""; 108 | }; 109 | ECDD40111D5EF2EC00EB3C85 /* Supporting Files */ = { 110 | isa = PBXGroup; 111 | children = ( 112 | ECDD40121D5EF2EC00EB3C85 /* main.m */, 113 | ); 114 | name = "Supporting Files"; 115 | sourceTree = ""; 116 | }; 117 | ECDD40511D5EF3FA00EB3C85 /* Classes */ = { 118 | isa = PBXGroup; 119 | children = ( 120 | ECDD40521D5EF3FA00EB3C85 /* AllCourse */, 121 | ECDD40591D5EF3FA00EB3C85 /* MoreMenu */, 122 | ECDD40621D5EF3FA00EB3C85 /* Other */, 123 | ECDD40671D5EF3FA00EB3C85 /* Sort */, 124 | ); 125 | path = Classes; 126 | sourceTree = ""; 127 | }; 128 | ECDD40521D5EF3FA00EB3C85 /* AllCourse */ = { 129 | isa = PBXGroup; 130 | children = ( 131 | ECDD40531D5EF3FA00EB3C85 /* Controllers */, 132 | ECDD40571D5EF3FA00EB3C85 /* Models */, 133 | ECDD40581D5EF3FA00EB3C85 /* Views */, 134 | ); 135 | path = AllCourse; 136 | sourceTree = ""; 137 | }; 138 | ECDD40531D5EF3FA00EB3C85 /* Controllers */ = { 139 | isa = PBXGroup; 140 | children = ( 141 | ECDD40541D5EF3FA00EB3C85 /* YZAllCourseViewController.h */, 142 | ECDD40551D5EF3FA00EB3C85 /* YZAllCourseViewController.m */, 143 | ECDD40561D5EF3FA00EB3C85 /* YZAllCourseViewController.xib */, 144 | ); 145 | path = Controllers; 146 | sourceTree = ""; 147 | }; 148 | ECDD40571D5EF3FA00EB3C85 /* Models */ = { 149 | isa = PBXGroup; 150 | children = ( 151 | ); 152 | path = Models; 153 | sourceTree = ""; 154 | }; 155 | ECDD40581D5EF3FA00EB3C85 /* Views */ = { 156 | isa = PBXGroup; 157 | children = ( 158 | ); 159 | path = Views; 160 | sourceTree = ""; 161 | }; 162 | ECDD40591D5EF3FA00EB3C85 /* MoreMenu */ = { 163 | isa = PBXGroup; 164 | children = ( 165 | ECDD405A1D5EF3FA00EB3C85 /* Controllers */, 166 | ECDD405E1D5EF3FA00EB3C85 /* Models */, 167 | ECDD405F1D5EF3FA00EB3C85 /* Views */, 168 | ); 169 | path = MoreMenu; 170 | sourceTree = ""; 171 | }; 172 | ECDD405A1D5EF3FA00EB3C85 /* Controllers */ = { 173 | isa = PBXGroup; 174 | children = ( 175 | ECDD405B1D5EF3FA00EB3C85 /* YZMoreMenuViewController.h */, 176 | ECDD405C1D5EF3FA00EB3C85 /* YZMoreMenuViewController.m */, 177 | ECDD405D1D5EF3FA00EB3C85 /* YZMoreMenuViewController.xib */, 178 | ); 179 | path = Controllers; 180 | sourceTree = ""; 181 | }; 182 | ECDD405E1D5EF3FA00EB3C85 /* Models */ = { 183 | isa = PBXGroup; 184 | children = ( 185 | ); 186 | path = Models; 187 | sourceTree = ""; 188 | }; 189 | ECDD405F1D5EF3FA00EB3C85 /* Views */ = { 190 | isa = PBXGroup; 191 | children = ( 192 | ECDD40601D5EF3FA00EB3C85 /* YZMoreMenuCell.h */, 193 | ECDD40611D5EF3FA00EB3C85 /* YZMoreMenuCell.m */, 194 | ); 195 | path = Views; 196 | sourceTree = ""; 197 | }; 198 | ECDD40621D5EF3FA00EB3C85 /* Other */ = { 199 | isa = PBXGroup; 200 | children = ( 201 | ECDD40631D5EF3FA00EB3C85 /* UIView+YZCategory.h */, 202 | ECDD40641D5EF3FA00EB3C85 /* UIView+YZCategory.m */, 203 | ECDD40651D5EF3FA00EB3C85 /* YZMenuButton.h */, 204 | ECDD40661D5EF3FA00EB3C85 /* YZMenuButton.m */, 205 | ); 206 | path = Other; 207 | sourceTree = ""; 208 | }; 209 | ECDD40671D5EF3FA00EB3C85 /* Sort */ = { 210 | isa = PBXGroup; 211 | children = ( 212 | ECDD40681D5EF3FA00EB3C85 /* Controllers */, 213 | ECDD406B1D5EF3FA00EB3C85 /* Models */, 214 | ECDD406C1D5EF3FA00EB3C85 /* Views */, 215 | ); 216 | path = Sort; 217 | sourceTree = ""; 218 | }; 219 | ECDD40681D5EF3FA00EB3C85 /* Controllers */ = { 220 | isa = PBXGroup; 221 | children = ( 222 | ECDD40691D5EF3FA00EB3C85 /* YZSortViewController.h */, 223 | ECDD406A1D5EF3FA00EB3C85 /* YZSortViewController.m */, 224 | ); 225 | path = Controllers; 226 | sourceTree = ""; 227 | }; 228 | ECDD406B1D5EF3FA00EB3C85 /* Models */ = { 229 | isa = PBXGroup; 230 | children = ( 231 | ); 232 | path = Models; 233 | sourceTree = ""; 234 | }; 235 | ECDD406C1D5EF3FA00EB3C85 /* Views */ = { 236 | isa = PBXGroup; 237 | children = ( 238 | ECDD406D1D5EF3FA00EB3C85 /* YZSortCell.h */, 239 | ECDD406E1D5EF3FA00EB3C85 /* YZSortCell.m */, 240 | ECDD406F1D5EF3FA00EB3C85 /* YZSortCell.xib */, 241 | ); 242 | path = Views; 243 | sourceTree = ""; 244 | }; 245 | ECDD40811D5EF7BE00EB3C85 /* YZPullDownMenu */ = { 246 | isa = PBXGroup; 247 | children = ( 248 | ECDD40821D5EF7BE00EB3C85 /* YZCover.h */, 249 | ECDD40831D5EF7BE00EB3C85 /* YZCover.m */, 250 | ECDD40841D5EF7BE00EB3C85 /* YZPullDownMenu.h */, 251 | ECDD40851D5EF7BE00EB3C85 /* YZPullDownMenu.m */, 252 | ); 253 | name = YZPullDownMenu; 254 | path = ../../YZPullDownMenu; 255 | sourceTree = ""; 256 | }; 257 | /* End PBXGroup section */ 258 | 259 | /* Begin PBXNativeTarget section */ 260 | ECDD400D1D5EF2EC00EB3C85 /* YZPullDownMenuDemo */ = { 261 | isa = PBXNativeTarget; 262 | buildConfigurationList = ECDD40251D5EF2EC00EB3C85 /* Build configuration list for PBXNativeTarget "YZPullDownMenuDemo" */; 263 | buildPhases = ( 264 | ECDD400A1D5EF2EC00EB3C85 /* Sources */, 265 | ECDD400B1D5EF2EC00EB3C85 /* Frameworks */, 266 | ECDD400C1D5EF2EC00EB3C85 /* Resources */, 267 | ); 268 | buildRules = ( 269 | ); 270 | dependencies = ( 271 | ); 272 | name = YZPullDownMenuDemo; 273 | productName = YZPullDownMenuDemo; 274 | productReference = ECDD400E1D5EF2EC00EB3C85 /* YZPullDownMenuDemo.app */; 275 | productType = "com.apple.product-type.application"; 276 | }; 277 | /* End PBXNativeTarget section */ 278 | 279 | /* Begin PBXProject section */ 280 | ECDD40061D5EF2EC00EB3C85 /* Project object */ = { 281 | isa = PBXProject; 282 | attributes = { 283 | LastUpgradeCheck = 0720; 284 | ORGANIZATIONNAME = yz; 285 | TargetAttributes = { 286 | ECDD400D1D5EF2EC00EB3C85 = { 287 | CreatedOnToolsVersion = 7.2.1; 288 | DevelopmentTeam = YKYB5YMSRP; 289 | }; 290 | }; 291 | }; 292 | buildConfigurationList = ECDD40091D5EF2EC00EB3C85 /* Build configuration list for PBXProject "YZPullDownMenuDemo" */; 293 | compatibilityVersion = "Xcode 3.2"; 294 | developmentRegion = English; 295 | hasScannedForEncodings = 0; 296 | knownRegions = ( 297 | en, 298 | Base, 299 | ); 300 | mainGroup = ECDD40051D5EF2EC00EB3C85; 301 | productRefGroup = ECDD400F1D5EF2EC00EB3C85 /* Products */; 302 | projectDirPath = ""; 303 | projectRoot = ""; 304 | targets = ( 305 | ECDD400D1D5EF2EC00EB3C85 /* YZPullDownMenuDemo */, 306 | ); 307 | }; 308 | /* End PBXProject section */ 309 | 310 | /* Begin PBXResourcesBuildPhase section */ 311 | ECDD400C1D5EF2EC00EB3C85 /* Resources */ = { 312 | isa = PBXResourcesBuildPhase; 313 | buildActionMask = 2147483647; 314 | files = ( 315 | ECDD40211D5EF2EC00EB3C85 /* LaunchScreen.storyboard in Resources */, 316 | ECDD401E1D5EF2EC00EB3C85 /* Assets.xcassets in Resources */, 317 | ECDD40711D5EF3FA00EB3C85 /* YZAllCourseViewController.xib in Resources */, 318 | ECDD401C1D5EF2EC00EB3C85 /* Main.storyboard in Resources */, 319 | ECDD40791D5EF3FA00EB3C85 /* YZSortCell.xib in Resources */, 320 | ECDD40731D5EF3FA00EB3C85 /* YZMoreMenuViewController.xib in Resources */, 321 | ); 322 | runOnlyForDeploymentPostprocessing = 0; 323 | }; 324 | /* End PBXResourcesBuildPhase section */ 325 | 326 | /* Begin PBXSourcesBuildPhase section */ 327 | ECDD400A1D5EF2EC00EB3C85 /* Sources */ = { 328 | isa = PBXSourcesBuildPhase; 329 | buildActionMask = 2147483647; 330 | files = ( 331 | ECDD40751D5EF3FA00EB3C85 /* UIView+YZCategory.m in Sources */, 332 | ECDD40741D5EF3FA00EB3C85 /* YZMoreMenuCell.m in Sources */, 333 | ECDD40721D5EF3FA00EB3C85 /* YZMoreMenuViewController.m in Sources */, 334 | ECDD40861D5EF7BE00EB3C85 /* YZCover.m in Sources */, 335 | ECDD40771D5EF3FA00EB3C85 /* YZSortViewController.m in Sources */, 336 | ECDD40781D5EF3FA00EB3C85 /* YZSortCell.m in Sources */, 337 | ECDD40191D5EF2EC00EB3C85 /* ViewController.m in Sources */, 338 | ECDD40161D5EF2EC00EB3C85 /* AppDelegate.m in Sources */, 339 | ECDD40871D5EF7BE00EB3C85 /* YZPullDownMenu.m in Sources */, 340 | ECDD40761D5EF3FA00EB3C85 /* YZMenuButton.m in Sources */, 341 | ECDD40701D5EF3FA00EB3C85 /* YZAllCourseViewController.m in Sources */, 342 | ECDD40131D5EF2EC00EB3C85 /* main.m in Sources */, 343 | ); 344 | runOnlyForDeploymentPostprocessing = 0; 345 | }; 346 | /* End PBXSourcesBuildPhase section */ 347 | 348 | /* Begin PBXVariantGroup section */ 349 | ECDD401A1D5EF2EC00EB3C85 /* Main.storyboard */ = { 350 | isa = PBXVariantGroup; 351 | children = ( 352 | ECDD401B1D5EF2EC00EB3C85 /* Base */, 353 | ); 354 | name = Main.storyboard; 355 | sourceTree = ""; 356 | }; 357 | ECDD401F1D5EF2EC00EB3C85 /* LaunchScreen.storyboard */ = { 358 | isa = PBXVariantGroup; 359 | children = ( 360 | ECDD40201D5EF2EC00EB3C85 /* Base */, 361 | ); 362 | name = LaunchScreen.storyboard; 363 | sourceTree = ""; 364 | }; 365 | /* End PBXVariantGroup section */ 366 | 367 | /* Begin XCBuildConfiguration section */ 368 | ECDD40231D5EF2EC00EB3C85 /* Debug */ = { 369 | isa = XCBuildConfiguration; 370 | buildSettings = { 371 | ALWAYS_SEARCH_USER_PATHS = NO; 372 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 373 | CLANG_CXX_LIBRARY = "libc++"; 374 | CLANG_ENABLE_MODULES = YES; 375 | CLANG_ENABLE_OBJC_ARC = YES; 376 | CLANG_WARN_BOOL_CONVERSION = YES; 377 | CLANG_WARN_CONSTANT_CONVERSION = YES; 378 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 379 | CLANG_WARN_EMPTY_BODY = YES; 380 | CLANG_WARN_ENUM_CONVERSION = YES; 381 | CLANG_WARN_INT_CONVERSION = YES; 382 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 383 | CLANG_WARN_UNREACHABLE_CODE = YES; 384 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 385 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 386 | COPY_PHASE_STRIP = NO; 387 | DEBUG_INFORMATION_FORMAT = dwarf; 388 | ENABLE_STRICT_OBJC_MSGSEND = YES; 389 | ENABLE_TESTABILITY = YES; 390 | GCC_C_LANGUAGE_STANDARD = gnu99; 391 | GCC_DYNAMIC_NO_PIC = NO; 392 | GCC_NO_COMMON_BLOCKS = YES; 393 | GCC_OPTIMIZATION_LEVEL = 0; 394 | GCC_PREPROCESSOR_DEFINITIONS = ( 395 | "DEBUG=1", 396 | "$(inherited)", 397 | ); 398 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 399 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 400 | GCC_WARN_UNDECLARED_SELECTOR = YES; 401 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 402 | GCC_WARN_UNUSED_FUNCTION = YES; 403 | GCC_WARN_UNUSED_VARIABLE = YES; 404 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 405 | MTL_ENABLE_DEBUG_INFO = YES; 406 | ONLY_ACTIVE_ARCH = YES; 407 | SDKROOT = iphoneos; 408 | }; 409 | name = Debug; 410 | }; 411 | ECDD40241D5EF2EC00EB3C85 /* Release */ = { 412 | isa = XCBuildConfiguration; 413 | buildSettings = { 414 | ALWAYS_SEARCH_USER_PATHS = NO; 415 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 416 | CLANG_CXX_LIBRARY = "libc++"; 417 | CLANG_ENABLE_MODULES = YES; 418 | CLANG_ENABLE_OBJC_ARC = YES; 419 | CLANG_WARN_BOOL_CONVERSION = YES; 420 | CLANG_WARN_CONSTANT_CONVERSION = YES; 421 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 422 | CLANG_WARN_EMPTY_BODY = YES; 423 | CLANG_WARN_ENUM_CONVERSION = YES; 424 | CLANG_WARN_INT_CONVERSION = YES; 425 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 426 | CLANG_WARN_UNREACHABLE_CODE = YES; 427 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 428 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 429 | COPY_PHASE_STRIP = NO; 430 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 431 | ENABLE_NS_ASSERTIONS = NO; 432 | ENABLE_STRICT_OBJC_MSGSEND = YES; 433 | GCC_C_LANGUAGE_STANDARD = gnu99; 434 | GCC_NO_COMMON_BLOCKS = YES; 435 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 436 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 437 | GCC_WARN_UNDECLARED_SELECTOR = YES; 438 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 439 | GCC_WARN_UNUSED_FUNCTION = YES; 440 | GCC_WARN_UNUSED_VARIABLE = YES; 441 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 442 | MTL_ENABLE_DEBUG_INFO = NO; 443 | SDKROOT = iphoneos; 444 | VALIDATE_PRODUCT = YES; 445 | }; 446 | name = Release; 447 | }; 448 | ECDD40261D5EF2EC00EB3C85 /* Debug */ = { 449 | isa = XCBuildConfiguration; 450 | buildSettings = { 451 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 452 | INFOPLIST_FILE = YZPullDownMenuDemo/Info.plist; 453 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 454 | PRODUCT_BUNDLE_IDENTIFIER = iThinker.YZPullDownMenuDemo; 455 | PRODUCT_NAME = "$(TARGET_NAME)"; 456 | }; 457 | name = Debug; 458 | }; 459 | ECDD40271D5EF2EC00EB3C85 /* Release */ = { 460 | isa = XCBuildConfiguration; 461 | buildSettings = { 462 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 463 | INFOPLIST_FILE = YZPullDownMenuDemo/Info.plist; 464 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 465 | PRODUCT_BUNDLE_IDENTIFIER = iThinker.YZPullDownMenuDemo; 466 | PRODUCT_NAME = "$(TARGET_NAME)"; 467 | }; 468 | name = Release; 469 | }; 470 | /* End XCBuildConfiguration section */ 471 | 472 | /* Begin XCConfigurationList section */ 473 | ECDD40091D5EF2EC00EB3C85 /* Build configuration list for PBXProject "YZPullDownMenuDemo" */ = { 474 | isa = XCConfigurationList; 475 | buildConfigurations = ( 476 | ECDD40231D5EF2EC00EB3C85 /* Debug */, 477 | ECDD40241D5EF2EC00EB3C85 /* Release */, 478 | ); 479 | defaultConfigurationIsVisible = 0; 480 | defaultConfigurationName = Release; 481 | }; 482 | ECDD40251D5EF2EC00EB3C85 /* Build configuration list for PBXNativeTarget "YZPullDownMenuDemo" */ = { 483 | isa = XCConfigurationList; 484 | buildConfigurations = ( 485 | ECDD40261D5EF2EC00EB3C85 /* Debug */, 486 | ECDD40271D5EF2EC00EB3C85 /* Release */, 487 | ); 488 | defaultConfigurationIsVisible = 0; 489 | defaultConfigurationName = Release; 490 | }; 491 | /* End XCConfigurationList section */ 492 | }; 493 | rootObject = ECDD40061D5EF2EC00EB3C85 /* Project object */; 494 | } 495 | -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo.xcodeproj/project.xcworkspace/xcuserdata/yuanzheng.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iThinkerYZ/YZPullDownMenuDemo/779b90cb2719c087ebb74b8cbf33c33de8b2fad8/YZPullDownMenuDemo/YZPullDownMenuDemo.xcodeproj/project.xcworkspace/xcuserdata/yuanzheng.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // YZPullDownMenuDemo 4 | // 5 | // Created by yz on 16/8/13. 6 | // Copyright © 2016年 yz. 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 | -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // YZPullDownMenuDemo 4 | // 5 | // Created by yz on 16/8/13. 6 | // Copyright © 2016年 yz. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // 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. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // 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. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // 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. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Assets.xcassets/NewSearch/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Assets.xcassets/NewSearch/搜索-更多-已选中.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "搜索-更多-已选中@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "搜索-更多-已选中@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Assets.xcassets/NewSearch/搜索-更多-已选中.imageset/搜索-更多-已选中@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iThinkerYZ/YZPullDownMenuDemo/779b90cb2719c087ebb74b8cbf33c33de8b2fad8/YZPullDownMenuDemo/YZPullDownMenuDemo/Assets.xcassets/NewSearch/搜索-更多-已选中.imageset/搜索-更多-已选中@2x.png -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Assets.xcassets/NewSearch/搜索-更多-已选中.imageset/搜索-更多-已选中@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iThinkerYZ/YZPullDownMenuDemo/779b90cb2719c087ebb74b8cbf33c33de8b2fad8/YZPullDownMenuDemo/YZPullDownMenuDemo/Assets.xcassets/NewSearch/搜索-更多-已选中.imageset/搜索-更多-已选中@3x.png -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Assets.xcassets/NewSearch/搜索-更多-未选中.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "搜索-更多-未选中@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "搜索-更多-未选中@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Assets.xcassets/NewSearch/搜索-更多-未选中.imageset/搜索-更多-未选中@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iThinkerYZ/YZPullDownMenuDemo/779b90cb2719c087ebb74b8cbf33c33de8b2fad8/YZPullDownMenuDemo/YZPullDownMenuDemo/Assets.xcassets/NewSearch/搜索-更多-未选中.imageset/搜索-更多-未选中@2x.png -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Assets.xcassets/NewSearch/搜索-更多-未选中.imageset/搜索-更多-未选中@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iThinkerYZ/YZPullDownMenuDemo/779b90cb2719c087ebb74b8cbf33c33de8b2fad8/YZPullDownMenuDemo/YZPullDownMenuDemo/Assets.xcassets/NewSearch/搜索-更多-未选中.imageset/搜索-更多-未选中@3x.png -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Assets.xcassets/NewSearch/标签-向上箭头.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "标签-向上箭头@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "标签-向上箭头@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Assets.xcassets/NewSearch/标签-向上箭头.imageset/标签-向上箭头@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iThinkerYZ/YZPullDownMenuDemo/779b90cb2719c087ebb74b8cbf33c33de8b2fad8/YZPullDownMenuDemo/YZPullDownMenuDemo/Assets.xcassets/NewSearch/标签-向上箭头.imageset/标签-向上箭头@2x.png -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Assets.xcassets/NewSearch/标签-向上箭头.imageset/标签-向上箭头@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iThinkerYZ/YZPullDownMenuDemo/779b90cb2719c087ebb74b8cbf33c33de8b2fad8/YZPullDownMenuDemo/YZPullDownMenuDemo/Assets.xcassets/NewSearch/标签-向上箭头.imageset/标签-向上箭头@3x.png -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Assets.xcassets/NewSearch/标签-向下箭头.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "标签-向下箭头@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "标签-向下箭头@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Assets.xcassets/NewSearch/标签-向下箭头.imageset/标签-向下箭头@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iThinkerYZ/YZPullDownMenuDemo/779b90cb2719c087ebb74b8cbf33c33de8b2fad8/YZPullDownMenuDemo/YZPullDownMenuDemo/Assets.xcassets/NewSearch/标签-向下箭头.imageset/标签-向下箭头@2x.png -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Assets.xcassets/NewSearch/标签-向下箭头.imageset/标签-向下箭头@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iThinkerYZ/YZPullDownMenuDemo/779b90cb2719c087ebb74b8cbf33c33de8b2fad8/YZPullDownMenuDemo/YZPullDownMenuDemo/Assets.xcassets/NewSearch/标签-向下箭头.imageset/标签-向下箭头@3x.png -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Assets.xcassets/NewSearch/选中对号.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "选中对号@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "选中对号@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Assets.xcassets/NewSearch/选中对号.imageset/选中对号@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iThinkerYZ/YZPullDownMenuDemo/779b90cb2719c087ebb74b8cbf33c33de8b2fad8/YZPullDownMenuDemo/YZPullDownMenuDemo/Assets.xcassets/NewSearch/选中对号.imageset/选中对号@2x.png -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Assets.xcassets/NewSearch/选中对号.imageset/选中对号@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iThinkerYZ/YZPullDownMenuDemo/779b90cb2719c087ebb74b8cbf33c33de8b2fad8/YZPullDownMenuDemo/YZPullDownMenuDemo/Assets.xcassets/NewSearch/选中对号.imageset/选中对号@3x.png -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/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 | -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Base.lproj/Main.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 | -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Classes/AllCourse/Controllers/YZAllCourseViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // YZAllCourseViewController.h 3 | // PullDownMenu 4 | // 5 | // Created by yz on 16/8/12. 6 | // Copyright © 2016年 yz. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface YZAllCourseViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Classes/AllCourse/Controllers/YZAllCourseViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // YZAllCourseViewController.m 3 | // PullDownMenu 4 | // 5 | // Created by yz on 16/8/12. 6 | // Copyright © 2016年 yz. All rights reserved. 7 | // 8 | 9 | #import "YZAllCourseViewController.h" 10 | extern NSString * const YZUpdateMenuTitleNote; 11 | static NSString * const categoryID = @"categoryID"; 12 | static NSString * const categoryDetailID = @"categoryDetailID"; 13 | 14 | @interface YZAllCourseViewController () 15 | /** 16 | * 分类tableView 17 | */ 18 | @property (weak, nonatomic) IBOutlet UITableView *categoryTableView; 19 | /** 20 | * 分类详情tableView 21 | */ 22 | @property (weak, nonatomic) IBOutlet UITableView *categoryDetailTableView; 23 | 24 | @property (strong, nonatomic) NSString *selectedCategory; 25 | 26 | @end 27 | 28 | @implementation YZAllCourseViewController 29 | 30 | - (void)viewDidLoad { 31 | [super viewDidLoad]; 32 | 33 | // Do any additional setup after loading the view from its nib. 34 | [self.categoryTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:categoryID]; 35 | [self.categoryDetailTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:categoryDetailID]; 36 | } 37 | 38 | - (void)viewWillAppear:(BOOL)animated 39 | { 40 | [super viewWillAppear:animated]; 41 | NSIndexPath *indexPath = [NSIndexPath indexPathForItem:0 inSection:0]; 42 | [self.categoryTableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone]; 43 | [self tableView:self.categoryTableView didSelectRowAtIndexPath:indexPath]; 44 | } 45 | 46 | #pragma mark - 47 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 48 | { 49 | if (tableView == self.categoryTableView) { 50 | // 左边的类别表格 👈 51 | return 5; 52 | 53 | } else { 54 | // 右边的类别详情表格 👉 55 | return 10; 56 | } 57 | } 58 | 59 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 60 | { 61 | if (tableView == self.categoryTableView) { 62 | // 左边的类别表格 👈 63 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:categoryID]; 64 | cell.textLabel.text = [NSString stringWithFormat:@"小学%ld",indexPath.row]; 65 | return cell; 66 | } 67 | 68 | // 右边的类别详情表格 👉 69 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:categoryDetailID]; 70 | cell.textLabel.text = [NSString stringWithFormat:@"%@ : 详%ld",_selectedCategory,indexPath.row]; 71 | 72 | return cell; 73 | 74 | } 75 | 76 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 77 | { 78 | if (tableView == self.categoryTableView) { 79 | UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 80 | // 左边的类别表格 👈 81 | _selectedCategory = cell.textLabel.text; 82 | 83 | // 刷新右边数据 84 | [self.categoryDetailTableView reloadData]; 85 | 86 | return; 87 | } 88 | 89 | // 右边的类别详情表格 👉 90 | UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 91 | 92 | // 更新菜单标题 93 | [[NSNotificationCenter defaultCenter] postNotificationName:YZUpdateMenuTitleNote object:self userInfo:@{@"title":cell.textLabel.text}]; 94 | } 95 | 96 | 97 | 98 | @end 99 | -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Classes/AllCourse/Controllers/YZAllCourseViewController.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 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Classes/MoreMenu/Controllers/YZMoreMenuViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // YZMoreMenuViewController.h 3 | // PullDownMenu 4 | // 5 | // Created by yz on 16/8/12. 6 | // Copyright © 2016年 yz. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface YZMoreMenuViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Classes/MoreMenu/Controllers/YZMoreMenuViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // YZMoreMenuViewController.m 3 | // PullDownMenu 4 | // 5 | // Created by yz on 16/8/12. 6 | // Copyright © 2016年 yz. All rights reserved. 7 | // 8 | 9 | #import "YZMoreMenuViewController.h" 10 | #import "YZMoreMenuCell.h" 11 | extern NSString * const YZUpdateMenuTitleNote; 12 | static NSString * const ID = @"cell"; 13 | 14 | @interface YZMoreMenuViewController () 15 | @property (weak, nonatomic) IBOutlet UITableView *tableView; 16 | @property (nonatomic, copy) NSArray *titleArray; 17 | // 记录选中的cell 18 | @property (nonatomic, copy) NSMutableArray *selectCells; 19 | @end 20 | 21 | @implementation YZMoreMenuViewController 22 | - (NSMutableArray *)selectCells 23 | { 24 | if (_selectCells == nil) { 25 | _selectCells = [NSMutableArray array]; 26 | } 27 | return _selectCells; 28 | } 29 | - (void)viewDidLoad { 30 | 31 | [super viewDidLoad]; 32 | 33 | // Do any additional setup after loading the view from its nib. 34 | _titleArray = @[@"全部",@"录播课",@"直播课",@"线下课"]; 35 | 36 | [self.tableView registerClass:[YZMoreMenuCell class] forCellReuseIdentifier:ID]; 37 | } 38 | 39 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 40 | { 41 | return _titleArray.count; 42 | } 43 | 44 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 45 | { 46 | YZMoreMenuCell *cell = [tableView dequeueReusableCellWithIdentifier:ID]; 47 | 48 | cell.textLabel.text = _titleArray[indexPath.row]; 49 | 50 | return cell; 51 | } 52 | 53 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 54 | { 55 | YZMoreMenuCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 56 | 57 | cell.isSelected = !cell.isSelected; 58 | 59 | // 判断是否点击全部 60 | if (indexPath.row == 0) { // 全部 61 | if (cell.isSelected == YES) { 62 | // 选中其他所有cell 63 | [self selectAllCell]; 64 | } else { 65 | // 取消所有cell选中 66 | [self unSelectAllCell]; 67 | } 68 | return; 69 | } 70 | 71 | // 没有点击全部cell 72 | 73 | // 记录选中的cell,肯定不是全部 74 | if (cell.isSelected) { 75 | [self.selectCells addObject:cell]; 76 | } else { 77 | [self.selectCells removeObject:cell]; 78 | } 79 | 80 | // 判断选择所有cell 81 | if (self.selectCells.count == _titleArray.count - 1) { 82 | // 选中全部cell(全部) 83 | [self selectTotalCell]; 84 | } else { 85 | // 取消选中全部cell(全部) 86 | [self unSelectTotalCell]; 87 | } 88 | 89 | 90 | } 91 | 92 | // 选中全部cell 93 | - (void)selectTotalCell 94 | { 95 | NSIndexPath *indexPath = [NSIndexPath indexPathForItem:0 inSection:0]; 96 | YZMoreMenuCell *cell = [self.tableView cellForRowAtIndexPath:indexPath]; 97 | cell.isSelected = YES; 98 | } 99 | 100 | // 取消全部cell 101 | - (void)unSelectTotalCell 102 | { 103 | NSIndexPath *indexPath = [NSIndexPath indexPathForItem:0 inSection:0]; 104 | YZMoreMenuCell *cell = [self.tableView cellForRowAtIndexPath:indexPath]; 105 | cell.isSelected = NO; 106 | } 107 | 108 | // 取消选中所有cell 109 | - (void)unSelectAllCell 110 | { 111 | // 取消之前所有选中cell 112 | [self.selectCells removeAllObjects]; 113 | 114 | NSInteger count = _titleArray.count; 115 | for (int i = 0; i < count; i++) { 116 | NSIndexPath *indexPath = [NSIndexPath indexPathForItem:i inSection:0]; 117 | YZMoreMenuCell *cell = [self.tableView cellForRowAtIndexPath:indexPath]; 118 | cell.isSelected = NO; 119 | } 120 | } 121 | 122 | // 选中所有cell 123 | - (void)selectAllCell 124 | { 125 | // 取消之前所有选中cell 126 | [self.selectCells removeAllObjects]; 127 | 128 | NSInteger count = _titleArray.count; 129 | for (int i = 0; i < count; i++) { 130 | NSIndexPath *indexPath = [NSIndexPath indexPathForItem:i inSection:0]; 131 | YZMoreMenuCell *cell = [self.tableView cellForRowAtIndexPath:indexPath]; 132 | cell.isSelected = YES; 133 | 134 | if (i > 0) { 135 | [self.selectCells addObject:cell]; 136 | } 137 | } 138 | } 139 | 140 | // 点击了确定 141 | - (IBAction)clickSure:(id)sender { 142 | NSArray *titles = [self.selectCells valueForKeyPath:@"textLabel.text"]; 143 | 144 | // 更新菜单标题 145 | [[NSNotificationCenter defaultCenter] postNotificationName:YZUpdateMenuTitleNote object:self userInfo:@{@"arr":titles}]; 146 | } 147 | 148 | @end 149 | -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Classes/MoreMenu/Controllers/YZMoreMenuViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Classes/MoreMenu/Views/YZMoreMenuCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // YZMoreMenuCell.h 3 | // PullDownMenu 4 | // 5 | // Created by yz on 16/8/13. 6 | // Copyright © 2016年 yz. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface YZMoreMenuCell : UITableViewCell 12 | 13 | @property (nonatomic, assign) BOOL isSelected; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Classes/MoreMenu/Views/YZMoreMenuCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // YZMoreMenuCell.m 3 | // PullDownMenu 4 | // 5 | // Created by yz on 16/8/13. 6 | // Copyright © 2016年 yz. All rights reserved. 7 | // 8 | 9 | #import "YZMoreMenuCell.h" 10 | 11 | @interface YZMoreMenuCell () 12 | 13 | @property (nonatomic, strong) UIButton *cheakView; 14 | 15 | @end 16 | 17 | @implementation YZMoreMenuCell 18 | 19 | - (UIButton *)cheakView 20 | { 21 | if (_cheakView == nil) { 22 | 23 | _cheakView = [UIButton buttonWithType:UIButtonTypeCustom]; 24 | 25 | _cheakView.userInteractionEnabled = NO; 26 | 27 | [_cheakView setImage:[UIImage imageNamed:@"搜索-更多-未选中"] forState:UIControlStateNormal]; 28 | 29 | [_cheakView setImage:[UIImage imageNamed:@"搜索-更多-已选中"] forState:UIControlStateSelected]; 30 | 31 | [_cheakView sizeToFit]; 32 | 33 | self.accessoryView = _cheakView; 34 | } 35 | return _cheakView; 36 | } 37 | 38 | - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier 39 | { 40 | if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { 41 | self.selectionStyle = UITableViewCellSelectionStyleNone; 42 | self.cheakView.hidden = NO; 43 | } 44 | return self; 45 | } 46 | - (void)setIsSelected:(BOOL)isSelected 47 | { 48 | _isSelected = isSelected; 49 | 50 | self.cheakView.selected = isSelected; 51 | } 52 | 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Classes/Other/UIView+YZCategory.h: -------------------------------------------------------------------------------- 1 | 2 | #import 3 | #import 4 | @interface UIView(YZSize) 5 | 6 | @property (nonatomic) CGFloat x; 7 | @property (nonatomic) CGFloat y; 8 | @property (nonatomic) CGFloat maxX; 9 | @property (nonatomic) CGFloat maxY; 10 | @property (nonatomic) CGFloat centerX; 11 | @property (nonatomic) CGFloat centerY; 12 | @property (nonatomic) CGFloat width; 13 | @property (nonatomic) CGFloat height; 14 | @property (nonatomic) CGPoint origin; 15 | @property (nonatomic) CGSize size; 16 | 17 | @end 18 | 19 | //////////////////////////////////////////////////////////// 20 | 21 | @interface UIView(Category) 22 | 23 | //获取该视图的控制器 24 | - (UIViewController*) viewController; 25 | 26 | //删除当前视图内的所有子视图 27 | - (void) removeChildViews; 28 | 29 | //删除tableview底部多余横线 30 | - (void)setExtraCellLineHidden: (UITableView *)tableView; 31 | @end -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Classes/Other/UIView+YZCategory.m: -------------------------------------------------------------------------------- 1 | 2 | #import "UIView+YZCategory.h" 3 | 4 | #pragma mark UIView (Size) 5 | 6 | @implementation UIView(YZSize) 7 | 8 | - (CGFloat)x { 9 | return self.frame.origin.x; 10 | } 11 | 12 | - (void)setX:(CGFloat)x { 13 | CGRect frame = self.frame; 14 | frame.origin.x = x; 15 | self.frame = frame; 16 | } 17 | 18 | - (CGFloat)y { 19 | return self.frame.origin.y; 20 | } 21 | 22 | - (void)setY:(CGFloat)y { 23 | CGRect frame = self.frame; 24 | frame.origin.y = y; 25 | self.frame = frame; 26 | } 27 | 28 | - (CGFloat)maxX { 29 | return self.frame.origin.x + self.frame.size.width; 30 | } 31 | 32 | - (void)setMaxX:(CGFloat)right { 33 | CGRect frame = self.frame; 34 | frame.origin.x = right - frame.size.width; 35 | self.frame = frame; 36 | } 37 | 38 | - (CGFloat)maxY { 39 | return self.frame.origin.y + self.frame.size.height; 40 | } 41 | 42 | - (void)setMaxY:(CGFloat)bottom { 43 | CGRect frame = self.frame; 44 | frame.origin.y = bottom - frame.size.height; 45 | self.frame = frame; 46 | } 47 | 48 | - (CGFloat)centerX { 49 | return self.center.x; 50 | } 51 | 52 | - (void)setCenterX:(CGFloat)centerX { 53 | self.center = CGPointMake(centerX, self.center.y); 54 | } 55 | 56 | - (CGFloat)centerY { 57 | return self.center.y; 58 | } 59 | 60 | - (void)setCenterY:(CGFloat)centerY { 61 | self.center = CGPointMake(self.center.x, centerY); 62 | } 63 | 64 | - (CGFloat)width { 65 | return self.frame.size.width; 66 | } 67 | 68 | - (void)setWidth:(CGFloat)width { 69 | CGRect frame = self.frame; 70 | frame.size.width = width; 71 | self.frame = frame; 72 | } 73 | 74 | - (CGFloat)height { 75 | return self.frame.size.height; 76 | } 77 | 78 | - (void)setHeight:(CGFloat)height { 79 | CGRect frame = self.frame; 80 | frame.size.height = height; 81 | self.frame = frame; 82 | } 83 | 84 | - (CGPoint)origin { 85 | return self.frame.origin; 86 | } 87 | 88 | - (void)setOrigin:(CGPoint)origin { 89 | CGRect frame = self.frame; 90 | frame.origin = origin; 91 | self.frame = frame; 92 | } 93 | 94 | - (CGSize)size { 95 | return self.frame.size; 96 | } 97 | 98 | - (void)setSize:(CGSize)size { 99 | CGRect frame = self.frame; 100 | frame.size = size; 101 | self.frame = frame; 102 | } 103 | 104 | @end 105 | 106 | //////////////////////////////////////////////////////////// 107 | 108 | @implementation UIView (Category) 109 | 110 | //获取该视图的控制器 111 | - (UIViewController*) viewController{ 112 | for (UIView* next = [self superview]; next; next = next.superview) { 113 | UIResponder* nextResponder = [next nextResponder]; 114 | if ([nextResponder isKindOfClass:[UIViewController class]]) { 115 | return (UIViewController*)nextResponder; 116 | } 117 | } 118 | return nil; 119 | } 120 | 121 | //删除当前视图内的所有子视图 122 | - (void) removeChildViews{ 123 | for (UIView *cv in self.subviews) { 124 | [cv removeFromSuperview]; 125 | } 126 | } 127 | //删除tableview底部多余横线 128 | - (void)setExtraCellLineHidden: (UITableView *)tableView 129 | { 130 | 131 | UIView *view = [UIView new]; 132 | 133 | view.backgroundColor = [UIColor clearColor]; 134 | 135 | [tableView setTableFooterView:view]; 136 | } 137 | @end -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Classes/Other/YZMenuButton.h: -------------------------------------------------------------------------------- 1 | // 2 | // YZMenuButton.h 3 | // PullDownMenu 4 | // 5 | // Created by yz on 16/8/12. 6 | // Copyright © 2016年 yz. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface YZMenuButton : UIButton 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Classes/Other/YZMenuButton.m: -------------------------------------------------------------------------------- 1 | // 2 | // YZMenuButton.m 3 | // PullDownMenu 4 | // 5 | // Created by yz on 16/8/12. 6 | // Copyright © 2016年 yz. All rights reserved. 7 | // 8 | 9 | #import "YZMenuButton.h" 10 | #import "UIView+YZCategory.h" 11 | 12 | @implementation YZMenuButton 13 | 14 | - (void)layoutSubviews 15 | { 16 | [super layoutSubviews]; 17 | 18 | if (self.imageView.x < self.titleLabel.x) { 19 | 20 | self.titleLabel.x = self.imageView.x; 21 | 22 | self.imageView.x = self.titleLabel.maxX + 10; 23 | } 24 | 25 | 26 | 27 | } 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Classes/Sort/Controllers/YZSortViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // YZSortViewController.h 3 | // PullDownMenu 4 | // 5 | // Created by yz on 16/8/12. 6 | // Copyright © 2016年 yz. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface YZSortViewController : UITableViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Classes/Sort/Controllers/YZSortViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // YZSortViewController.m 3 | // PullDownMenu 4 | // 5 | // Created by yz on 16/8/12. 6 | // Copyright © 2016年 yz. All rights reserved. 7 | // 8 | 9 | #import "YZSortViewController.h" 10 | #import "YZSortCell.h" 11 | extern NSString * const YZUpdateMenuTitleNote; 12 | static NSString * const ID = @"cell"; 13 | 14 | @interface YZSortViewController () 15 | @property (nonatomic, copy) NSArray *titleArray; 16 | @property (nonatomic, assign) NSInteger selectedCol; 17 | @end 18 | 19 | @implementation YZSortViewController 20 | 21 | - (void)viewDidLoad { 22 | [super viewDidLoad]; 23 | // Do any additional setup after loading the view from its nib. 24 | 25 | _selectedCol = 0; 26 | 27 | _titleArray = @[@"综合排序",@"人气排序",@"评分排序",@"评价最多"]; 28 | 29 | [self.tableView registerClass:[YZSortCell class] forCellReuseIdentifier:ID]; 30 | 31 | } 32 | 33 | - (void)viewWillAppear:(BOOL)animated 34 | { 35 | [super viewWillAppear:animated]; 36 | NSIndexPath *indexPath = [NSIndexPath indexPathForItem:_selectedCol inSection:0]; 37 | [self.tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone]; 38 | } 39 | 40 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 41 | { 42 | return self.titleArray.count; 43 | } 44 | 45 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 46 | { 47 | YZSortCell *cell = [tableView dequeueReusableCellWithIdentifier:ID]; 48 | cell.textLabel.text = _titleArray[indexPath.row]; 49 | if (indexPath.row == 0) { 50 | [cell setSelected:YES animated:NO]; 51 | } 52 | 53 | return cell; 54 | } 55 | 56 | 57 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 58 | { 59 | _selectedCol = indexPath.row; 60 | 61 | // 选中当前 62 | YZSortCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 63 | 64 | // 更新菜单标题 65 | [[NSNotificationCenter defaultCenter] postNotificationName:YZUpdateMenuTitleNote object:self userInfo:@{@"title":cell.textLabel.text}]; 66 | 67 | 68 | } 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Classes/Sort/Views/YZSortCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // YZSortCell.h 3 | // PullDownMenu 4 | // 5 | // Created by yz on 16/8/13. 6 | // Copyright © 2016年 yz. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface YZSortCell : UITableViewCell 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Classes/Sort/Views/YZSortCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // YZSortCell.m 3 | // PullDownMenu 4 | // 5 | // Created by yz on 16/8/13. 6 | // Copyright © 2016年 yz. All rights reserved. 7 | // 8 | 9 | #import "YZSortCell.h" 10 | 11 | @interface YZSortCell () 12 | 13 | @property (nonatomic, strong) UIImageView *cheakView; 14 | 15 | @end 16 | 17 | @implementation YZSortCell 18 | 19 | - (UIImageView *)cheakView 20 | { 21 | if (_cheakView == nil) { 22 | _cheakView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"选中对号"]]; 23 | self.accessoryView = _cheakView; 24 | } 25 | return _cheakView; 26 | } 27 | 28 | - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier 29 | { 30 | if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { 31 | self.selectionStyle = UITableViewCellSelectionStyleNone; 32 | } 33 | return self; 34 | } 35 | 36 | - (void)setSelected:(BOOL)selected animated:(BOOL)animated 37 | { 38 | [super setSelected:selected animated:animated]; 39 | self.cheakView.hidden = !selected; 40 | } 41 | 42 | - (void)awakeFromNib { 43 | // Initialization code 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/Classes/Sort/Views/YZSortCell.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/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 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // YZPullDownMenuDemo 4 | // 5 | // Created by yz on 16/8/13. 6 | // Copyright © 2016年 yz. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // YZPullDownMenuDemo 4 | // 5 | // Created by yz on 16/8/13. 6 | // Copyright © 2016年 yz. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "YZPullDownMenu.h" 11 | #import "YZMenuButton.h" 12 | #import "YZMoreMenuViewController.h" 13 | #import "YZSortViewController.h" 14 | #import "YZAllCourseViewController.h" 15 | 16 | #define YZScreenW [UIScreen mainScreen].bounds.size.width 17 | #define YZScreenH [UIScreen mainScreen].bounds.size.height 18 | 19 | @interface ViewController () 20 | @property (nonatomic, strong) NSArray *titles; 21 | @end 22 | 23 | @implementation ViewController 24 | 25 | - (void)viewDidLoad { 26 | [super viewDidLoad]; 27 | 28 | // Do any additional setup after loading the view, typically from a nib. 29 | self.view.backgroundColor = [UIColor brownColor]; 30 | 31 | // 创建下拉菜单 32 | YZPullDownMenu *menu = [[YZPullDownMenu alloc] init]; 33 | menu.frame = CGRectMake(0, 20, YZScreenW, 44); 34 | [self.view addSubview:menu]; 35 | 36 | // 设置下拉菜单代理 37 | menu.dataSource = self; 38 | 39 | // 初始化标题 40 | _titles = @[@"小学",@"排序",@"更多"]; 41 | 42 | // 添加子控制器 43 | [self setupAllChildViewController]; 44 | } 45 | 46 | #pragma mark - 添加子控制器 47 | - (void)setupAllChildViewController 48 | { 49 | YZAllCourseViewController *allCourse = [[YZAllCourseViewController alloc] init]; 50 | YZSortViewController *sort = [[YZSortViewController alloc] init]; 51 | YZMoreMenuViewController *moreMenu = [[YZMoreMenuViewController alloc] init]; 52 | [self addChildViewController:allCourse]; 53 | [self addChildViewController:sort]; 54 | [self addChildViewController:moreMenu]; 55 | } 56 | 57 | #pragma mark - YZPullDownMenuDataSource 58 | // 返回下拉菜单多少列 59 | - (NSInteger)numberOfColsInMenu:(YZPullDownMenu *)pullDownMenu 60 | { 61 | return 3; 62 | } 63 | 64 | // 返回下拉菜单每列按钮 65 | - (UIButton *)pullDownMenu:(YZPullDownMenu *)pullDownMenu buttonForColAtIndex:(NSInteger)index 66 | { 67 | YZMenuButton *button = [YZMenuButton buttonWithType:UIButtonTypeCustom]; 68 | [button setTitle:_titles[index] forState:UIControlStateNormal]; 69 | [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; 70 | [button setTitleColor:[UIColor colorWithRed:25 /255.0 green:143/255.0 blue:238/255.0 alpha:1] forState:UIControlStateSelected]; 71 | [button setImage:[UIImage imageNamed:@"标签-向下箭头"] forState:UIControlStateNormal]; 72 | [button setImage:[UIImage imageNamed:@"标签-向上箭头"] forState:UIControlStateSelected]; 73 | 74 | return button; 75 | } 76 | 77 | // 返回下拉菜单每列对应的控制器 78 | - (UIViewController *)pullDownMenu:(YZPullDownMenu *)pullDownMenu viewControllerForColAtIndex:(NSInteger)index 79 | { 80 | return self.childViewControllers[index]; 81 | } 82 | 83 | // 返回下拉菜单每列对应的高度 84 | - (CGFloat)pullDownMenu:(YZPullDownMenu *)pullDownMenu heightForColAtIndex:(NSInteger)index 85 | { 86 | // 第1列 高度 87 | if (index == 0) { 88 | return 400; 89 | } 90 | 91 | // 第2列 高度 92 | if (index == 1) { 93 | return 180; 94 | } 95 | 96 | // 第3列 高度 97 | return 240; 98 | } 99 | 100 | 101 | @end 102 | -------------------------------------------------------------------------------- /YZPullDownMenuDemo/YZPullDownMenuDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // YZPullDownMenuDemo 4 | // 5 | // Created by yz on 16/8/13. 6 | // Copyright © 2016年 yz. 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 | --------------------------------------------------------------------------------