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

    .

  • 相关阅读:
    更好地限制一个UITextField的输入长度
    训练集(train set) 验证集(validation set) 测试集(test set)
    主流机器学习[xgb, lgb, Keras, LR]
    python pandas (ix & iloc &loc) 的区别
    机器学习:数据预处理之独热编码(One-Hot)
    SPARK第一天
    Spark简介
    scatter
    协方差和相关关系
    SQL存储过程
  • 原文地址:https://www.cnblogs.com/huen/p/3871675.html
Copyright © 2011-2022 走看看