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

    .

  • 相关阅读:
    python中a = a+b与a += b的不同
    python中的全局变量global
    python中星号(*)和双星号(**)的用法
    python循环语句
    python逻辑运算符
    python内置函数 print()
    python 解析迅雷下载链接
    python 正则表达式
    python 读写文件
    python selenium操作cookie
  • 原文地址:https://www.cnblogs.com/huen/p/3871675.html
Copyright © 2011-2022 走看看