//
//  UINavigationController+Customized.m
//  DingDCommunity
//
//  Created by JianjiYuan on 14-3-3.
//  Copyright (c) 2014年 JianjiYuan. All rights reserved.
//

#import "UINavigationController+Customized.h"

@implementation UINavigationController (Customized)

- (void)navbarLeftItemCustomized:(NSArray *)arrBtns onwer:(UINavigationItem *)onwer
{
    NSMutableArray *arrTemp = [NSMutableArray arrayWithCapacity:4];
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
        UIBarButtonItem *flexSpacer = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
                                                                                   target:self
                                                                                   action:nil];
        flexSpacer.width = -7;
        [arrTemp addObject:flexSpacer];
    }
    for (int i = 0; i< arrBtns.count; i++) {
        UIBarButtonItem *barItem = [[UIBarButtonItem alloc] initWithCustomView:arrBtns[i]];
        [arrTemp addObject:barItem];
        
    }

    [onwer setLeftBarButtonItems:arrTemp];
    
}

- (void)navbarRightItemCustomized:(NSArray *)arrBtns onwer:(UINavigationItem *)onwer
{
    NSMutableArray *arrTemp = [NSMutableArray arrayWithCapacity:4];
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
        UIBarButtonItem *flexSpacer = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
                                                                                   target:self
                                                                                   action:nil];
        flexSpacer.width = -10;
        [arrTemp addObject:flexSpacer];
    }
    for (int i = 0; i< arrBtns.count; i++) {
        UIBarButtonItem *barItem = [[UIBarButtonItem alloc] initWithCustomView:arrBtns[i]];
        [arrTemp addObject:barItem];
        
    }
    [onwer setRightBarButtonItems:arrTemp];
    
}

@end
