美文网首页UI进价iOS程序猿IOS
AYNavigationBar-自定义导航栏替换UINaviga

AYNavigationBar-自定义导航栏替换UINaviga

作者: Pircate | 来源:发表于2017-12-11 13:42 被阅读65次

    AYNavigationBar

    Overview

    Installation

    Use CocoaPods 

      pod 'AYNavigationBar'

    Usage

    Import

      #import "AYNavigationBar.h"

    To enable AYNavigationBar of a navigation controller

      UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];

      nav.ay_navigation.configuration.enabled = YES;

    Setting

    global setting

      UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];

      nav.ay_navigation.configuration.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor blueColor]};

      nav.ay_navigation.configuration.barTintColor = [UIColor cyanColor];

      nav.ay_navigation.configuration.backgroundImage = [UIImage imageNamed:@"nav"];

      nav.ay_navigation.configuration.shadowImage = [UIImage imageNamed:@"shadow"];

      nav.ay_navigation.configuration.extraHeight = 14;

    each setting

    normal

      self.ay_navigation.bar  -> UINavigationBar

      self.ay_navigation.item -> UINavigationItem

    additional

      // override alpha & backgroundColor

      self.ay_navigation.bar.alpha -> UINavigationBar.barBackgroundView.alpha

      self.ay_navigation.bar.backgroundColor -> UINavigationBar.barTintColor

    largeTitle(iOS 11.0+)

      // enable

      if (@available(iOS 11.0, *)) {

          self.navigationController.navigationBar.prefersLargeTitles = YES; // once

      }

      // show

      if (@available(iOS 11.0, *)) {

          self.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeAlways;

      }

      // hide

      if (@available(iOS 11.0, *)) {

          self.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeNever;

      }

    相关文章

      网友评论

        本文标题:AYNavigationBar-自定义导航栏替换UINaviga

        本文链接:https://www.haomeiwen.com/subject/rkeiixtx.html