码迷,mamicode.com
首页 > 移动开发 > 详细

ios nav自定义button

时间:2016-03-10 20:17:32      阅读:304      评论:0      收藏:0      [点我收藏+]

标签:

 

 

 

技术分享

 

 

+(void)initialize{
    
    UINavigationBar *item = [UINavigationBar appearance];
    
    // 按钮的颜色
    item.tintColor = [UIColor redColor];
    // 整个背景的颜色
    item.barTintColor = [UIColor orangeColor];

}

 

    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    dic[NSForegroundColorAttributeName] = [UIColor whiteColor];
    
    UINavigationBar *item = [UINavigationBar appearance];
    [item setTitleTextAttributes:dic];
    
    [item setBackgroundImage:[UIImage imageNamed:@"top"] forBarMetrics:UIBarMetricsDefault];

 

 

 

 UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        [btn setBackgroundImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
        [btn setBackgroundImage:[UIImage imageNamed:@"back_hover"] forState:UIControlStateSelected];
        
        [btn setTitle:@"返回" forState:UIControlStateNormal];
        btn.titleLabel.font = [UIFont systemFontOfSize:15];
        [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        btn.size = CGSizeMake(50, 29);
//        btn.backgroundColor = [UIColor lightGrayColor];
        
//        btn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
//        btn.contentEdgeInsets = UIEdgeInsetsMake(0, -50, 0, 0);
        
        [btn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
        viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btn];

 

ios nav自定义button

标签:

原文地址:http://www.cnblogs.com/kinghx/p/5263144.html

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