Git Product home page Git Product logo

yiplee / ypnavigationbartransition Goto Github PK

View Code? Open in Web Editor NEW
829.0 12.0 100.0 8.79 MB

A Full functional UINavigationBar framework for making bar transition more natural! You don't need to call any UINavigationBar api, implementing YPNavigationBarConfigureStyle protocol for your view controller instead. (类似微信 iOS Navigation Bar 的切换方案)

License: MIT License

Objective-C 95.99% Ruby 3.48% Shell 0.53%
navigationbar transition statusbar uinavigationcontroller navigation bar transparent translucent swift

ypnavigationbartransition's Introduction

YPNavigationBarTransition

Build Status Pods Version Carthage Compatible

A Fully functional UINavigationBar framework for making bar transition more natural! You don't need to call any UINavigationBar api, implementing YPNavigationBarConfigureStyle protocol for your view controller instead.

类似微信 UINavigationBar 效果的切换方案,支持任意透明半透明图片背景等等不同样式的 UINavigationBar 的切换。

features

  • Transparent & translucent navigation bar 支持不透明、全透明和半透明的 navigation bar
  • Pure color bar 支持设置 navigation bar 背景颜色
  • Background image bar 支持设置 navigation bar 背景图片
  • Update navigationBar style dynamicly 可以动态调整 navigation bar 样式
  • Written in Objective-C with full Swift interop support

不同颜色和透明度的 bar 之间的切换

图片背景的 navigation bar

动态调整 navigation bar 样式

Requirements

  • Xcode 9.0+
  • iOS 8.0+

Installation

CocoaPods

The preferred installation method is with CocoaPods. Add the following to your Podfile:

# use_frameworks! is needed for swift projects
use_frameworks!
pod 'YPNavigationBarTransition', '~> 2.0'

Carthage

For Carthage, add the following to your Cartfile:

github "yiplee/YPNavigationBarTransition" ~> 2.0

Getting Started

1. Import Framework

// objc
#import <YPNavigationBarTransition/YPNavigationBarTransition.h>
// swift
import YPNavigationBarTransition

2. Replace UINavigationController with YPNavigationController

3. Implement Protocol YPNavigationBarConfigureStyle for YPNavigationController in Category

// objc (this will be your app's default navigationbar style)
@implementation YPNavigationController (Configure)

- (YPNavigationBarConfigurations) yp_navigtionBarConfiguration {
    return YPNavigationBarStyleBlack | YPNavigationBarBackgroundStyleTranslucent | YPNavigationBarBackgroundStyleNone;
}

- (UIColor *) yp_navigationBarTintColor {
    return [UIColor whiteColor];
}
// swift (this will be your app's default navigationbar style)
extension YPNavigationController : NavigationBarConfigureStyle {
    public func yp_navigtionBarConfiguration() -> YPNavigationBarConfigurations {
        return [.styleBlack]
    }

    public func yp_navigationBarTintColor() -> UIColor! {
        return UIColor.white
    }
}

License

MIT. See the LICENSE file for details.

ypnavigationbartransition's People

Contributors

1036938520 avatar dependabot[bot] avatar janyave avatar john-gods avatar kinarobin avatar liaoworking avatar yiplee avatar z-hui avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ypnavigationbartransition's Issues

2.0.9 版本第一次切换闪烁

在2.0.9版本中,第一次从图片切换到背景颜色会导致导航栏闪烁,之后就不会了,而在2.0.8中没有这种问题,希望能改进下

How to use with subclass of UINavigationController?

Follow the instruction of YPNavigationController, but method validateInnerNavigationDelegate and variable navigationController does not exist. So what should i do if i want to make a UINavigatioController subclass to use in the project?

设置 extendedLayoutIncludesOpaqueBars 为 true 还是会引起 tableView 跳动一下

A push B

全局默认设置:
extension YPNavigationController : NavigationBarConfigureStyle {
public func yp_navigtionBarConfiguration() -> YPNavigationBarConfigurations {
return [.backgroundStyleColor, .backgroundStyleOpaque]
}

public func yp_navigationBarTintColor() -> UIColor! {
return UIColor.white
}

public func yp_navigationBackgroundColor() -> UIColor! {
return Specs.color.tint
}
}

A 设置: (设置 extendedLayoutIncludesOpaqueBars 为 true )
extension A : NavigationBarConfigureStyle {
public func yp_navigtionBarConfiguration() -> YPNavigationBarConfigurations {
return [.backgroundStyleTransparent]
}

public func yp_navigationBarTintColor() -> UIColor! {
return UIColor.white
}
}

B 设置:

extension B : NavigationBarConfigureStyle {
public func yp_navigtionBarConfiguration() -> YPNavigationBarConfigurations {
return [.backgroundStyleColor, .backgroundStyleOpaque]
}

public func yp_navigationBarTintColor() -> UIColor! {
return UIColor.white
}

func yp_navigationBackgroundColor() -> UIColor! {
return UIColor(hex: 0x40362E)
}
}

使用这个框架后代码强制横屏失败

AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
// 打开横屏开关
appDelegate.allowRotation = YES;
// 调用转屏代码
[UIDevice deviceMandatoryLandscapeWithNewOrientation:UIInterfaceOrientationLandscapeRight];

/// 输入要强制转屏的方向
/// @param interfaceOrientation 转屏的方向

  • (void)deviceMandatoryLandscapeWithNewOrientation:(UIInterfaceOrientation)interfaceOrientation {

    NSNumber *resetOrientationTarget = [NSNumber numberWithInt:UIInterfaceOrientationUnknown];

    [[UIDevice currentDevice] setValue:resetOrientationTarget forKey:@"orientation"];

    // 将输入的转屏方向(枚举)转换成Int类型
    int orientation = (int)interfaceOrientation;

    // 对象包装
    NSNumber *orientationTarget = [NSNumber numberWithInt:orientation];

    // 实现横竖屏旋转
    [[UIDevice currentDevice] setValue:orientationTarget forKey:@"orientation"];
    }

如何在Translucent时排除状态栏?

  • (YPNavigationBarConfigurations) yp_navigtionBarConfiguration {
    return YPNavigationBarBackgroundStyleTranslucent | YPNavigationBarBackgroundStyleColor;
    }

  • (UIColor *) yp_navigationBarTintColor {
    return [UIColor redColor];
    }

  • (UIColor *) yp_navigationBackgroundColor {
    return [UIColor whiteColor];
    }

目前视图向上滚动时会出现在naviagtionbar和statusbar下面,如何排除statusbar使Translucent效果只出现在naviagtionbar?

Example for Swift

Unfortunately I can not figure out how to use your library in Swift. If possible, rewrite the same example on Swift.

新版模态方式,会引起闪退

不是全屏的模态,模态界面下拉再回弹会crash

[toVC.view removeObserver:self
forKeyPath:NSStringFromSelector(@selector(bounds))
context:&ctx];

这里移除了不存在的观察者
新版的模态不走willshow代理

無法返回

demo 上下滑動完後, 有時可以側滑返回,有時又不行,不知是否是bug

请问这里为什么要生成一个透明的configuration,这样会导致fakebar的frame有问题

   if (showFakeBar) {
        YPNavigationBarConfigurations transparentConf = YPNavigationBarConfigurationsDefault | YPNavigationBarBackgroundStyleTransparent;
        if (showConfigure.barStyle == UIBarStyleBlack) transparentConf |= YPNavigationBarStyleBlack;
        transparentConfigure = [[YPBarConfiguration alloc] initWithBarConfigurations:transparentConf
                                                                           tintColor:showConfigure.tintColor
                                                                     backgroundColor:nil
                                                                     backgroundImage:nil
                                                           backgroundImageIdentifier:nil];
    }

怎么能够动态控制 pop 手势?

你好,非常感谢你的开源资源,我很喜欢这个库。
因为业务需求,需求需要动态控制页面的 pop 手势,或者是在退出页面时进行一些操作,例如弹框提示用户是否保留数据之类;但看到库中把并没有暴露相关API,有时间的话,希望能解决这个问题呢,再次感谢。

self.navigationItem.rightBarButtonItem设置后未生效

A页面push到B页面, 在B页面中设置self.navigationItem.rightBarButtonItem,问题如下:
首次push到B页面后,rightBarButtonItem短暂出现,但是很快就消失不见了
再次进入后,可以正常显示。

yp_navigationBackgroundImageWithIdentifier 咨询

  • (UIImage *) yp_navigationBackgroundImageWithIdentifier:(NSString *__autoreleasing *)identifier {
    if (identifier) *identifier = _backgroundImageName;
    return _backgroundImage;
    }
    swift 语法 if (identifier) *identifier = _backgroundImageName; 该如何写呢?

swift can not use styleLight

public func yp_navigtionBarConfiguration() -> YPNavigationBarConfigurations {
return [.styleLight]
}

.styleLight 无效

iOS13暗黑模式

请问大佬啥时候可以更新暗黑模式呀?我看状态栏新增了UIStatusBarStyleDarkContent这个模式

Swift 如何实现呀 感觉有点懵呢

  • (YPNavigationBarConfigurations) yp_navigtionBarConfiguration {
    YPNavigationBarConfigurations configurations = YPNavigationBarShow;
    if (_gradientProgress < 0.5) {
    configurations |= YPNavigationBarStyleBlack;
    }

    if (_gradientProgress == 1) {
    configurations |= YPNavigationBarBackgroundStyleOpaque;
    }

    configurations |= YPNavigationBarBackgroundStyleColor;
    return configurations;
    }

这段代码 如何转向Swift

例如 这:
YPNavigationBarConfigurations configurations = YPNavigationBarShow;
configurations |= YPNavigationBarStyleBlack;

并且Swift中 不调用 .show (YPNavigationBarShow) 这个枚举
谢谢

iOS 13下,设置tintColor失效

条件:当视图控制器不使用titleLabel,直接设置self.title时
现象:字体颜色会是黑色
情况说明:代理中设置的tintColor(白色)失效。

为什么不透明的时候不能设置图片和背景颜色

   if (!(configurations & YPNavigationBarBackgroundStyleTransparent)) {
        if (configurations & YPNavigationBarBackgroundStyleImage) {
            backgroundImage = [owner yp_navigationBackgroundImageWithIdentifier:&imageIdentifier];
        } else if (configurations & YPNavigationBarBackgroundStyleColor) {
            backgroundColor = [owner yp_navigationBackgroundColor];
        }
   }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.