zoukankan      html  css  js  c++  java
  • 自定义导航栏

    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)
        {
            
        }];
    }

    .

  • 相关阅读:
    eclipse的下载安装
    找不到符号 类string
    [转]Android_开源框架_AndroidUniversalImageLoader网络图片加载
    [转]移动web开发经验总结
    测试一下吧
    javascript 的 encodeURIComponent 函数用 Objective-C 实现
    几个Objective-C的HTML解析库
    html test
    一段测试代码
    [转]Embed WebView in Fragment
  • 原文地址:https://www.cnblogs.com/huen/p/3871675.html
Copyright © 2011-2022 走看看