一个受 Evernote 5.0 应用程序启发,用于组织多个导航控制器的堆叠控件
注意:KLNoteViewController 旨在用于 iPhone/iPad/iPod Touch 的纵向方向。
查看演示 请原谅我的慢速电脑造成的图形故障和延迟。
将包含的 KLNoteViewController.h, KLNoteViewController.m
文件拖动到您的项目中。然后,在 Link Binary With Libraries 下包含以下框架
导入头文件并声明您的控制器为 KLNoteViewController 的子类 #import "KLNoteViewController.h"
@interface KLRootViewController : KLNoteViewController
或者,导入头文件并声明您的控制器遵循 KLNoteViewControllerDataSource 和 KLNoteViewControllerDelegate
#import "KLNoteViewController.h"
@interface KLRootViewController : UIViewController <KLNoteViewControllerDataSource, KLNoteViewControllerDelegate>
@property(nonatomic, strong) KLNoteViewController* noteViewController;
实现数据源所需的方法
- (NSInteger)numberOfControllerCardsInNoteView:(KLNoteViewController*) noteView;
- (UIViewController *)noteView:(KLNoteViewController*)noteView viewControllerForRowAtIndexPath:(NSIndexPath *)indexPath;
示例 - 应根据您的需要更改
- (NSInteger)numberOfControllerCardsInNoteView:(KLNoteViewController*) noteView {
return [self.viewControllers count];
}
- (UIViewController *)noteView:(KLNoteViewController*)noteView viewControllerForRowAtIndexPath:(NSIndexPath *)indexPath {
//Get the relevant data for the navigation controller
NSDictionary* navDict = [self.navigationControllers objectAtIndex: indexPath.row];
//Initialize a blank uiviewcontroller for display purposes
UIStoryboard *st = [UIStoryboard storyboardWithName:[[NSBundle mainBundle].infoDictionary objectForKey:@"UIMainStoryboardFile"] bundle:[NSBundle mainBundle]];
KLCustomViewController* viewController = [st instantiateViewControllerWithIdentifier:@"RootViewController"];
[viewController setInfo: navDict];
//Return the custom view controller
return viewController;
}
实现当卡片状态改变时被通知的可选代理方法
//Called on any time a state change has occured - even if a state has changed to itself - (i.e. from KLControllerCardStateDefault to KLControllerCardStateDefault)
-(void) noteViewController: (KLNoteViewController*) noteViewController didUpdateControllerCard:(KLControllerCard*)controllerCard toDisplayState:(KLControllerCardState) toState fromDisplayState:(KLControllerCardState) fromState;
可以通过更改 KLNoteViewController.m
中的常量来调整视觉外观
//Layout properties
#define kDefaultMinimizedScalingFactor 0.98 //Amount to shrink each card from the previous one
#define kDefaultMaximizedScalingFactor 1.00 //Maximum a card can be scaled to
#define kDefaultNavigationBarOverlap 0.90 //Defines vertical overlap of each navigation toolbar. Slight hack that prevents rounding errors from showing the whitespace between navigation toolbars. Can be customized if require more/less packing of navigation toolbars
//Animation properties
#define kDefaultAnimationDuration 0.3 //Amount of time for the animations to occur
#define kDefaultReloadHideAnimationDuration 0.4
#define kDefaultReloadShowAnimationDuration 0.6
//Position for the stack of navigation controllers to originate at
#define kDefaultVerticalOrigin 100 //Vertical origin of the controller card stack. Making this value larger/smaller will make the card shift down/up.
//Corner radius properties
#define kDefaultCornerRadius 5.0
//Shadow Properties - Note : Disabling shadows greatly improves performance and fluidity of animations
#define kDefaultShadowEnabled YES
#define kDefaultShadowColor [UIColor blackColor]
#define kDefaultShadowOffset CGSizeMake(0, -5)
#define kDefaultShadowRadius kDefaultCornerRadius
#define kDefaultShadowOpacity 0.60
//Gesture properties
#define kDefaultMinimumPressDuration 0.2
版权所有 (c) 2012 Kieran Lafferty
特此授予任何人免费获得此软件及相关文档副本("软件")的副本的权利,用于在不限制的情况下处理软件,包括但不限于使用、复制、修改、合并、出版、分发、再许可和/或销售软件副本,并允许获得软件副本的个人做此类操作,前提如下
上述版权声明和本许可声明应包含在软件的所有副本或主要部分中。
本软件按照“现状”提供,不提供任何明确或隐含的保证,包括但不限于商销性、适合特定目的性和非侵权性保证。在任何情况下,作者或版权所有者均不对任何主张、损害或其他责任负有责任,无论源于合同、侵权或其他,与软件或其使用或其他方式有关。