码迷,mamicode.com
首页 > 其他好文 > 详细

美团HD(2)-设置导航栏内容

时间:2017-01-04 00:15:45      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:class   ati   search   ant   blog   ons   button   技术   collect   

 

DJHomeViewController.m

#import "DJHomeViewController.h"
#import "DJConstantValue.h"
#import "DJNavTopItem.h"

@implementation DJHomeViewController


- (instancetype)init {

    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    return [self initWithCollectionViewLayout:layout];
}


- (void)viewDidLoad {

    [super viewDidLoad];
    self.collectionView.backgroundColor = DJColor(230, 230, 230);
    
    [self setupRightNavItem];
    [self setupLeftNavItem];

}


/** 设置导航栏右侧内容 */
- (void)setupRightNavItem {

    // 地图
    UIBarButtonItem *mapItem = [UIBarButtonItem itemWithTarget:self action:nil image:@"icon_map" highlighImage:@"icon_map_highlighted"];
    mapItem.customView.width = 50;
//    mapItem.customView.backgroundColor = [UIColor redColor];
    
    // 搜索
    UIBarButtonItem *searchItem = [UIBarButtonItem itemWithTarget:self action:nil image:@"icon_search" highlighImage:@"icon_search_highlighted"];
    searchItem.customView.width = 50;
//    searchItem.customView.backgroundColor = [UIColor greenColor];

    self.navigationItem.rightBarButtonItems = @[mapItem,searchItem];

}


/** 设置导航栏左侧内容 */
- (void)setupLeftNavItem {

    UIImageView *logoView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_meituan_logo"]];
    UIBarButtonItem *logoItem = [[UIBarButtonItem alloc] initWithCustomView:logoView];
    
    
    DJNavTopItem *item01 = [DJNavTopItem item];
    UIBarButtonItem *item1 = [[UIBarButtonItem alloc] initWithCustomView:item01];
    
    DJNavTopItem *item02 = [DJNavTopItem item];
    UIBarButtonItem *item2 = [[UIBarButtonItem alloc] initWithCustomView:item02];
    
    DJNavTopItem *item03 = [DJNavTopItem item];
    UIBarButtonItem *item3 = [[UIBarButtonItem alloc] initWithCustomView:item03];
    
    self.navigationItem.leftBarButtonItems = @[logoItem,item1,item2,item3];
    
    
}


@end

最终效果:

技术分享

 

美团HD(2)-设置导航栏内容

标签:class   ati   search   ant   blog   ons   button   技术   collect   

原文地址:http://www.cnblogs.com/yongdaimi/p/6246805.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!