南京律师网站建设,支付宝小程序开发工具,江苏山海连云建设有限公司网站,机械配件采购平台前言 iOS 常见的几种架构#xff1a; 标签式 Tab Menu列表式 List Menu抽屉式 Drawer瀑布式 Waterfall跳板式 Springborad陈列馆式 Gallery旋转木马式 Carousel点聚式 Plus1、标签式 优点#xff1a; 1、清楚当前所在的入口位置2、轻松在各入口间频繁跳转且不会迷失方向3、直…前言 iOS 常见的几种架构 标签式 Tab Menu列表式 List Menu抽屉式 Drawer瀑布式 Waterfall跳板式 Springborad陈列馆式 Gallery旋转木马式 Carousel点聚式 Plus1、标签式 优点 1、清楚当前所在的入口位置2、轻松在各入口间频繁跳转且不会迷失方向3、直接展现最重要入口的内容信息 缺点 功能入口过多时该模式显得笨重不实用 2、列表式 优点 1、层次展示清晰2、可展示内容较长的标题3、可展示标题的次级内容 缺点 1、同级内容过多时用户浏览容易产生疲劳2、排版灵活性不是很高3、只能通过排列顺序、颜色来区分各入口重要程度 3、抽屉式 优点 1、兼容多种模式2、扩展性好 缺点 1、隐藏框架中其他入口2、对入口交互的功能可见性affordance要求高 3.1 抽屉式架构简单实现 ViewController.m #import ViewController.h#import QCMainViewController.h#import QCDrawerViewController.h// 设定抽屉视图的宽度#define DRAWER_VC_WIDTH ((self.view.bounds.size.width * 3) / 4)interface ViewController ()property (nonatomic, strong) QCMainViewController *mainVC;property (nonatomic, strong) UINavigationController *mainNVC;property (nonatomic, strong) QCDrawerViewController *drawerVC;endimplementation ViewController- (void)viewDidLoad {[super viewDidLoad];// 添加主视图self.mainVC [[QCMainViewController alloc] init];self.mainNVC [[UINavigationController alloc] initWithRootViewController:self.mainVC];[self addChildViewController:self.mainNVC];[self.view addSubview:self.mainNVC.view];// 添加抽屉视图self.drawerVC [[QCDrawerViewController alloc] init];self.drawerVC.view.frame CGRectMake(-DRAWER_VC_WIDTH, 0, DRAWER_VC_WIDTH, self.view.bounds.size.height);[self addChildViewController:self.drawerVC];[self.view addSubview:self.drawerVC.view];// 抽屉视图显示隐藏回调__weak typeof(self) weakSelf self;self.mainVC.myBlock ^(BOOL isPush){CGRect mainNVCFrame weakSelf.self.mainNVC.view.bounds;CGRect drawerVCFrame weakSelf.self.drawerVC.view.bounds;mainNVCFrame.origin.x isPush ? DRAWER_VC_WIDTH : 0;drawerVCFrame.origin.x isPush ? 0 : -DRAWER_VC_WIDTH;[UIView animateWithDuration:0.5 animations:^{weakSelf.mainNVC.view.frame mainNVCFrame;weakSelf.drawerVC.view.frame drawerVCFrame;}];};}endQCMainViewController.h #import UIKit/UIKit.hinterface QCMainViewController : UIViewControllerproperty (nonatomic, copy) void (^myBlock)(BOOL);endQCMainViewController.m #import QCMainViewController.hinterface QCMainViewController ()property (nonatomic, assign, getter isPush) BOOL push;endimplementation QCMainViewController- (void)viewDidLoad {[super viewDidLoad];self.view.backgroundColor [UIColor yellowColor];self.navigationItem.leftBarButtonItem [[UIBarButtonItem alloc] initWithTitle:抽屉 style:UIBarButtonItemStylePlain target:self action:selector(pushDrawer)];// 功能测试for (NSUInteger i 0; i 5; i) {UIButton *btn [[UIButton alloc] init];[self.view addSubview:btn];btn.frame CGRectMake(20, 200 i * 60, 100, 50);btn.tag i 1;[btn setTitle:[NSString stringWithFormat:按钮 %li, i 1] forState:UIControlStateNormal];[btn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];[btn addTarget:self action:selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];}}// 功能测试- (void)btnClick:(UIButton *)btn {NSLog(按钮 %li, btn.tag);}// 抽屉视图显示隐藏- (void)pushDrawer {self.push !self.isPush;if (self.myBlock ! nil) {self.myBlock(self.isPush);}}// 触摸手势抽屉视图显示隐藏- (void)touchesBegan:(NSSetUITouch * *)touches withEvent:(UIEvent *)event {if (self.isPush) {[self pushDrawer];}}endQCDrawerViewController.m #import QCDrawerViewController.hinterface QCDrawerViewController ()endimplementation QCDrawerViewController- (void)viewDidLoad {[super viewDidLoad];self.view.backgroundColor [UIColor blueColor];// 功能测试for (NSUInteger i 0; i 5; i) {UIButton *btn [[UIButton alloc] init];[self.view addSubview:btn];btn.frame CGRectMake(20, 200 i * 60, 100, 50);btn.tag i 1;[btn setTitle:[NSString stringWithFormat:功能 %li, i 1] forState:UIControlStateNormal];[btn addTarget:self action:selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];}}// 功能测试- (void)btnClick:(UIButton *)btn {NSLog(功能 %li, btn.tag);}end效果 3.2 抽屉式架构第三方框架实现 第三方框架 GitHub 地址效果 4、瀑布式 优点 1、浏览时产生流畅体验 缺点 1、缺乏对整体内容的体积感容易发生空间位置迷失2、浏览一段时间后容易产生疲劳感 5、跳板式 优点 1、清晰展现各入口2、容易记住各入口位置方便快速找到 缺点 1、无法在多入口间灵活跳转不适合多任务操作2、容易形成更深的路径3、不能直接展现入口内容4、不能显示太多入口次级内容 6、陈列馆式 优点 1、直观展现各项内容2、方便浏览经常更新的内容 缺点 1、不适合展现顶层入口框架2、容易形成界面内容过多显得杂乱3、设计效果容易呆板 7、旋转木马式 优点 1、单页面内容整体性强2、线性的浏览方式有顺畅感、方向感 缺点 1、不适合展示过多页面2、不能跳跃性地查看间隔的页面只能按顺序查看相邻的页面3、由于各页面内容结构相似容易忽略后面的内容 8、点聚式 优点 1、灵活2、展示方式有趣3、使界面更开阔 缺点 1、隐藏框架中其他入口2、对入口交互的功能可见性affordance要求高