All Projects → Roen-Ro → Rrviewcontrollerextension

Roen-Ro / Rrviewcontrollerextension

Licence: mit
UINavigationBar appearance management, memory leak detection, convenient UIViewController property and methods

Programming Languages

objc
23 projects

Projects that are alternatives of or similar to Rrviewcontrollerextension

SPLarkController
Custom transition between controllers. Settings controller for your iOS app.
Stars: ✭ 967 (+627.07%)
Mutual labels:  uiviewcontroller
Topasscodeviewcontroller
A modal passcode input and validation view controller for iOS
Stars: ✭ 373 (+180.45%)
Mutual labels:  uiviewcontroller
Licensingviewcontroller
📃 UIViewController subclass with a simple API for displaying licensing information.
Stars: ✭ 107 (-19.55%)
Mutual labels:  uiviewcontroller
UIMediaAlertController
UIAlertController extension for selecting images.
Stars: ✭ 19 (-85.71%)
Mutual labels:  uiviewcontroller
Scrollstackcontroller
🧩 Easy scrollable layouts in UIKit
Stars: ✭ 281 (+111.28%)
Mutual labels:  uiviewcontroller
Splarkcontroller
Custom transition between controllers. Settings controller for your iOS app.
Stars: ✭ 693 (+421.05%)
Mutual labels:  uiviewcontroller
Jelly
🌊 - Jelly is a library for animated, non-interactive & interactive viewcontroller transitions and presentations with the focus on a simple and yet flexible API.
Stars: ✭ 2,319 (+1643.61%)
Mutual labels:  uiviewcontroller
Xlbubbletransition
iOS ViewController间切换的转场动画
Stars: ✭ 127 (-4.51%)
Mutual labels:  uiviewcontroller
Knphotobrowser
📷 图片 || 视频 浏览器(本地和网络) , UIViewController + CollectionView , 完美适配 iPhone 以及 iPad ,屏幕旋转功能 , 适配SDWebImage 5.0
Stars: ✭ 296 (+122.56%)
Mutual labels:  uiviewcontroller
Panslip
Use PanGesture to dismiss view on UIViewController and UIView
Stars: ✭ 93 (-30.08%)
Mutual labels:  uiviewcontroller
CustomSegueDemo
Demonstrates encapsulation of a custom view controller transition into a UIStoryboardSegue subclass
Stars: ✭ 31 (-76.69%)
Mutual labels:  uiviewcontroller
ViewDidAppearFirstTime
🙈 Adds viewWillAppearFirstTime(_:) and viewDidAppearFirstTime(_:) to UIViewController
Stars: ✭ 14 (-89.47%)
Mutual labels:  uiviewcontroller
Realm Loginkit
A generic interface for logging in to Realm Mobile Platform apps
Stars: ✭ 70 (-47.37%)
Mutual labels:  uiviewcontroller
AutoInsetter
📐 Easily provide custom view controller auto-insetting
Stars: ✭ 13 (-90.23%)
Mutual labels:  uiviewcontroller
Towebviewcontroller
A view controller class for iOS that allows users to view web pages directly within an app.
Stars: ✭ 1,500 (+1027.82%)
Mutual labels:  uiviewcontroller
Lnpopupcontroller
LNPopupController is a framework for presenting view controllers as popups of other view controllers, much like the Apple Music and Podcasts apps.
Stars: ✭ 2,807 (+2010.53%)
Mutual labels:  uiviewcontroller
Gknavigationbarviewcontroller
iOS自定义导航栏-导航栏联动
Stars: ✭ 637 (+378.95%)
Mutual labels:  uiviewcontroller
Aicustomviewcontrollertransition
Easy and tidy way for creating custom UIViewController transitions for iOS
Stars: ✭ 130 (-2.26%)
Mutual labels:  uiviewcontroller
Swifty360player
iOS 360-degree video player streaming from an AVPlayer.
Stars: ✭ 118 (-11.28%)
Mutual labels:  uiviewcontroller
Swiftassetspickercontroller
A simple assets picker controller based on iOS 8 Photos framework. Supports iCloud photos and videos. It's written in Swift.
Stars: ✭ 81 (-39.1%)
Mutual labels:  uiviewcontroller

RRViewControllerExtension

A lightweight UIViewController category extension for UINavigationBar appearance management, view controller push/pop/dismiss management, memory leak detection and other convenient property and methods. Benefits include:

  • Manage UINavigationBar appearance gracefully
  • Automatic viewController memory leak detection with out any code modification.
  • Push/pop with completion block call back block
  • UIViewController life cycle method hook
  • Other convenient properties

Reference to this demo on github, 中文介绍戳这里

Preview

Usage

UINavigationBar appearance management

make specific UINavigationBar bar appearance specific for each viewcontroller staticly or dynamicly just by overriding method of your viewcontroller, which are defined in UIViewController+RRExtension.h

//override any of the methods below in your viewcontroller's .m file to make specific navigation bar appearance

-(BOOL)prefersNavigationBarHidden;
-(BOOL)prefersNavigationBarTransparent;

-(nullable UIColor *)preferredNavatationBarColor;
-(nullable UIColor *)preferredNavigationItemColor;
-(nullable UIImage *)preferredNavigationBarBackgroundImage;
-(nullable NSDictionary *)preferredNavigationTitleTextAttributes;

Make UINavigationBar bar appearance dynamic change, call [self updateNavigationAppearance:YES]; in your viewcontroller's .m file to force the update. A typical example:


    //typically in your UIScrollViewDelegate method
    - (void)scrollViewDidScroll:(UIScrollView *)scrollView
    {
        BOOL mode;
        if(scrollView.contentOffset.y > 300)
            mode = NO;
        else
            mode = YES;

        if(mode != _previewMode)
        {
            _previewMode = mode;

            //force navigation appearance update
            [self updateNavigationAppearance:YES];
        }
    }
    
    -(BOOL)prefersNavigationBarTransparent
    {
        if(_previewMode)
            return NO;
        else
            return YES;
    }
    
    -(nullable UIColor *)preferredNavigationItemColor
    {
        if(_previewMode)
            return [UIColor whiteColor];
        else
            return [UIColor blackColor];;
    }

You can specify default UINavigationBar appearance by using [[UINavigationBar appearance] setXXX:] globally.


[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:0 green:0.45 blue:0.8 alpha:1.0]];
[[UINavigationBar appearance] setTintColor:[UIColor redColor]];
NSDictionary * dict = [NSDictionary dictionaryWithObject:[UIColor yellowColor] forKey:NSForegroundColorAttributeName];
[[UINavigationBar appearance] setTitleTextAttributes:dict];

You can also specify the default UINavigationBar appearance for each UINavigationController instance by setting properties defined in UINavigationController+RRSet.h


// set default navigation bar appearance
@property (nonatomic) BOOL defaultNavigationBarHidden;
@property (nonatomic) BOOL defaultNavigationBarTransparent;

@property (nonatomic,copy) UIColor *defaultNavatationBarColor;
@property (nonatomic,copy) UIColor *defaultNavigationItemColor;
@property (nonatomic,strong) UIImage *defaultNavigationBarBackgroundImage;
@property (nonatomic,copy) NSDictionary *defaultNavigationTitleTextAttributes;

Memory leak detection

to detect memory leak on runtime for viewcontrollers, all you have to do is just import the RRViewControllerExtension to your project. whenever a memory leak happened, there will be a alert show on your app.

you can also spcify which class of UIViewController or more precisely on which UIViewController instance you want to do the memory leak detection by reference to methods below in UIViewController+RRExtension.h

//Unavailable in release mode. \
in debug mode, defalut is NO for classes returned from +memoryLeakDetectionExcludedClasses method and YES for others
@property (nonatomic,getter = memoryLeakDetectionEnabled) BOOL enabledMemoryLeakDetection;

//read and add or remove values from the returned set to change default excluded memory detection classes
+(NSMutableSet<NSString *> *)memoryLeakDetectionExcludedClasses;

//for subclass to override
-(void)didReceiveMemoryLeakWarning;

viewController life cylcle hook

hook any of the UIViewController life cycylcle method before or after execution, for instacne if you want to track the user page viewing behavior, you just need to write code in your AppDelgate.m like:


//log the user enter page behavior
[UIViewController hookLifecycle:RRViewControllerLifeCycleViewWillAppear
                       onTiming:RRMethodInsertTimingBefore
                      withBlock:^(UIViewController * _Nonnull viewController, BOOL animated) {

                        [MyLog logEnterPage:NSStringFromClass([viewController class])];
                    }];
            
            
//log the user leaving page behavior
[UIViewController hookLifecycle:RRViewControllerLifeCycleViewDidDisappear
                       onTiming:RRMethodInsertTimingAfter
                      withBlock:^(UIViewController * _Nonnull viewController, BOOL animated) {

                        [MyLog logLeavePage:NSStringFromClass([viewController class])];
                    }];

Installation

To install using CocoaPods, add the following to your project Podfile:

pod 'RRViewControllerExtension'

and in your project file importing by:

#import <RRViewControllerExtension.h>

Alternatively, drag and drop RRViewControllerExtension directory from this code project into your Xcode project, importing files by:

#import "RRViewControllerExtension.h"

TODO

fix bug Hide navigation back arrow after reset the stack by: -[UINavigationController setViewControllers:]

Author

Roen (罗亮富), [email protected]

Licenses

All source code is licensed under the MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].