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

自定义导航栏

时间:2014-07-31 09:42:35      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   使用   io   for   cti   代码   

1.设置导航栏样式

    [self.navigationBar setBackgroundImage:[UIImage imageNamed:@"navibarbackground"] forBarMetrics:UIBarMetricsDefault];
    [self.navigationBar setTintColor:[UIColor whiteColor]];//BarItem颜色
    NSShadow *shadow = [NSShadow new];
    shadow.shadowColor = [UIColor blackColor];
    shadow.shadowOffset = CGSizeMake(3, 3);
    
    [self.navigationBar  setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName:[UIFont fontWithName:@"AmericanTypewriter"size:23],NSShadowAttributeName:shadow}];

 2.

不想标题栏是光秃秃的文字?您可以通过使用代码行中的图像或标志取代它:

1    self.navigationItem.titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"appcoda-logo.png"]];

3.导航栏入栈动画

-(IBAction)pushAction:(id)sender
{
    CATransition *animation = [CATransition animation];
    [animation setDuration:1.3];
    [animation setType:kCATransitionFade]; //淡入淡出
    [animation setSubtype:kCATransitionFromLeft];
    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
    SecondViewController *second = [SecondViewController new];
    [self.navigationController pushViewController:second animated:NO];
    [self.navigationController.view.layer addAnimation:animation forKey:nil];
    
}

通过类目为导航栏添加动画的方法

#import "UINavigationController+CustomPushOrPop.h"

@implementation UINavigationController (CustomPushOrPop)

-(void)customPushViewContrller:(UIViewController *)viewContrller
{
    viewContrller.view.frame = CGRectMake(0,-viewContrller.view.frame.size.height, self.view.frame.size.width, self.view.frame.size.height);
    [self pushViewController:viewContrller animated:NO];
    [UIView animateWithDuration:0.35f animations:^
    {
        viewContrller.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
    }
    completion:^(BOOL finished)
    {
        
    }];
}

.

 

自定义导航栏,布布扣,bubuko.com

自定义导航栏

标签:style   blog   color   使用   io   for   cti   代码   

原文地址:http://www.cnblogs.com/huen/p/3871675.html

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