DevStore首页 > DEV资源 > 源码下载 > 源码详情

实现面包屑样式的导航栏,可以用来指示步骤

 
15302a | 2014-09-10 20:44    浏览量(1963)    评论(4)    收藏(3)
功能分类:工具 支持平台:iOS 运行环境:iOS
开发语言:Object-c 开发工具:Xcode 源码大小:44.70KB
下载源码 134 人下载

源码简介

实现面包屑导航栏,可以用在指示步骤的视图中,当前视图所代表的步骤数显示在面包屑导航栏中。需要指示用户完成一系列步骤操作时,可以用这种形式的导航条。

源码截图

  • 运行截图
  • 运行截图
  • 运行截图
DevStore所有源码来自用户上传分享,版权问题及牵扯到商业纠纷均与DevStore无关。

源码片段

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.view addSubview:self.stepViewControllerContainer];
    [self.view addSubview:self.stepsBar];
    
    RMStepsBar *stepsBar = self.stepsBar;
    UIView *container = self.stepViewControllerContainer;
    
    NSDictionary *bindingsDict = NSDictionaryOfVariableBindings(stepsBar, container);
    
    [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-(0)-[stepsBar]" options:0 metrics:nil views:bindingsDict]];
    [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-(0)-[container]-(0)-|" options:0 metrics:nil views:bindingsDict]];
    [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|-0-[stepsBar]-0-|" options:0 metrics:nil views:bindingsDict]];
    [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|-0-[container]-0-|" options:0 metrics:nil views:bindingsDict]];
    
    NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:self.stepsBar attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.topLayoutGuide attribute:NSLayoutAttributeBaseline multiplier:1 constant:44];
    [self.view addConstraint:constraint];
    
    [self loadStepViewControllers];
    [self showStepViewController:[self.childViewControllers objectAtIndex:0] animated:NO];
}

#pragma mark - Properties
- (NSMutableDictionary *)results {
    if(!_results) {
        self.results = [@{} mutableCopy];
    }
    
    return _results;
}

- (RMStepsBar *)stepsBar {
    if(!_stepsBar) {
        self.stepsBar = [[RMStepsBar alloc] initWithFrame:CGRectZero];
        _stepsBar.delegate = self;
        _stepsBar.dataSource = self;
    }
    
    return _stepsBar;
}

- (UIView *)stepViewControllerContainer {
    if(!_stepViewControllerContainer) {
        self.stepViewControllerContainer = [[UIView alloc] initWithFrame:CGRectZero];
        _stepViewControllerContainer.translatesAutoresizingMaskIntoConstraints = NO;
    }
    
    return _stepViewControllerContainer;
}
#pragma mark - Helper
- (BOOL)extendViewControllerBelowBars:(UIViewController *)aViewController {
    return (aViewController.extendedLayoutIncludesOpaqueBars || (aViewController.edgesForExtendedLayout & UIRectEdgeTop));
}

- (void)updateContentInsetsForViewController:(UIViewController *)aViewController {
    if([self extendViewControllerBelowBars:aViewController]) {
        UIEdgeInsets insets = UIEdgeInsetsZero;
        insets.top += self.stepsBar.frame.size.height;
        
        [aViewController adaptToEdgeInsets:insets];
    }
}

- (void)loadStepViewControllers {
    NSArray *stepViewControllers = [self stepViewControllers];
    NSAssert([stepViewControllers count] > 0, @"Fatal: At least one step view controller must be returned by +[%@ stepViewControllers].", [self class]);
    for(UIViewController *aViewController in stepViewControllers) {
        NSAssert([aViewController isKindOfClass:[UIViewController class]], @"Fatal: %@ is not a subclass from UIViewController. Only UIViewControllers are supported by RMStepsController as steps.", [aViewController class]); 
        aViewController.stepsController = self; 
        [aViewController willMoveToParentViewController:self];
        [self addChildViewController:aViewController];
        [aViewController didMoveToParentViewController:self];
    }
    
    [self.stepsBar reloadData];
}
  •   赞(0) 赞 +1 赞(0) 已赞
  •   收藏(3) 收藏 +1 已收藏 取消
  •   下载(134)
评论(4)
xiaoming7173

xiaoming7173 2015-02-13 20:13:46

挺好的,腻害
回复(0) 赞(0) 赞(1)
struggle198654101

struggle198654101 2014-12-17 18:01:53

下载了,谢谢了
回复(0) 赞(0) 赞(1)
souapp

souapp 2014-09-28 09:59:07

下载了,谢谢了
回复(0) 赞(0) 赞(1)
tianxiataguo

tianxiataguo 2014-09-11 17:41:38

很厉害的样子,就是界面有待提高
回复(0) 赞(0) 赞(1)
  • 推荐
  • 审核
  • 收录
  • 获取活力值

源码上传作者

  • 14 能力值
  • 5 源码
  • 0 评测
  • 0 资料

热门源码