{"id":23845774,"url":"https://github.com/roen-ro/rrviewcontrollerextension","last_synced_at":"2025-03-21T20:14:19.252Z","repository":{"id":33084357,"uuid":"149244201","full_name":"Roen-Ro/RRViewControllerExtension","owner":"Roen-Ro","description":" UINavigationBar appearance management, memory leak detection, convenient UIViewController property and methods","archived":false,"fork":false,"pushed_at":"2024-09-20T02:15:27.000Z","size":1895,"stargazers_count":136,"open_issues_count":0,"forks_count":17,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-21T20:14:14.039Z","etag":null,"topics":["ios","objc","objective-c","uinavigationcontroller","uiviewcontroller"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Roen-Ro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-18T07:10:13.000Z","updated_at":"2024-11-23T08:57:28.000Z","dependencies_parsed_at":"2025-02-28T13:14:47.795Z","dependency_job_id":"5d789fda-9415-4f1e-ae4a-f7b2c4eaa025","html_url":"https://github.com/Roen-Ro/RRViewControllerExtension","commit_stats":null,"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Roen-Ro%2FRRViewControllerExtension","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Roen-Ro%2FRRViewControllerExtension/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Roen-Ro%2FRRViewControllerExtension/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Roen-Ro%2FRRViewControllerExtension/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Roen-Ro","download_url":"https://codeload.github.com/Roen-Ro/RRViewControllerExtension/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244860609,"owners_count":20522466,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ios","objc","objective-c","uinavigationcontroller","uiviewcontroller"],"created_at":"2025-01-02T20:26:26.301Z","updated_at":"2025-03-21T20:14:19.222Z","avatar_url":"https://github.com/Roen-Ro.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [RRViewControllerExtension](https://github.com/Roen-Ro/RRViewControllerExtension)\n\n\nA lightweight UIViewController category extension for UINavigationBar  appearance management, view controller push/pop/dismiss management, ViewController view statistics，memory leak detection and other convenient property and methods. Benefits include:\n\n- Manage `UINavigationBar` appearance gracefully\n- Automatic viewController memory leak detection with out any code modification.\n- Push/pop with completion block call back block\n- `UIViewController` life cycle method hook\n- ViewController view statistics\n- Other convenient properties\n\nReference to [this demo](https://github.com/Roen-Ro/RRViewControllerExtension) on github, [中文介绍戳这里](https://www.jianshu.com/p/59aba25692fe)。\n\n## Preview\n![](https://github.com/Roen-Ro/DemoResources/blob/master/RRUIViewControllerExtensio/rrvc004.gif?raw=true)\n\n## Usage\n\n### `UINavigationBar` appearance management\nmake 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`\n\n```objective-c\n//override any of the methods below in your viewcontroller's .m file to make specific navigation bar appearance\n\n-(BOOL)prefersNavigationBarHidden;\n-(BOOL)prefersNavigationBarTransparent;\n\n-(nullable UIColor *)preferredNavatationBarColor;\n-(nullable UIColor *)preferredNavigationItemColor;\n-(nullable UIImage *)preferredNavigationBarBackgroundImage;\n-(nullable NSDictionary *)preferredNavigationTitleTextAttributes;\n```\nMake `UINavigationBar`   bar appearance dynamic change, call `[self updateNavigationAppearance:YES];`  in your viewcontroller's .m file to force the update.\nA typical example:\n\n```objective-c\n\n    //typically in your UIScrollViewDelegate method\n    - (void)scrollViewDidScroll:(UIScrollView *)scrollView\n    {\n        BOOL mode;\n        if(scrollView.contentOffset.y \u003e 300)\n            mode = NO;\n        else\n            mode = YES;\n\n        if(mode != _previewMode)\n        {\n            _previewMode = mode;\n\n            //force navigation appearance update\n            [self updateNavigationAppearance:YES];\n        }\n    }\n    \n    -(BOOL)prefersNavigationBarTransparent\n    {\n        if(_previewMode)\n            return NO;\n        else\n            return YES;\n    }\n    \n    -(nullable UIColor *)preferredNavigationItemColor\n    {\n        if(_previewMode)\n            return [UIColor whiteColor];\n        else\n            return [UIColor blackColor];;\n    }\n\n```\n\n\nYou can specify default `UINavigationBar`  appearance by using `[[UINavigationBar appearance] setXXX:]` globally.\n\n```objective-c\n\n[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:0 green:0.45 blue:0.8 alpha:1.0]];\n[[UINavigationBar appearance] setTintColor:[UIColor redColor]];\nNSDictionary * dict = [NSDictionary dictionaryWithObject:[UIColor yellowColor] forKey:NSForegroundColorAttributeName];\n[[UINavigationBar appearance] setTitleTextAttributes:dict];\n\n```\n\nYou can also specify the default  `UINavigationBar`  appearance for each `UINavigationController` instance by setting properties defined in `UINavigationController+RRSet.h`\n```objective-c\n\n// set default navigation bar appearance\n@property (nonatomic) BOOL defaultNavigationBarHidden;\n@property (nonatomic) BOOL defaultNavigationBarTransparent;\n\n@property (nonatomic,copy) UIColor *defaultNavatationBarColor;\n@property (nonatomic,copy) UIColor *defaultNavigationItemColor;\n@property (nonatomic,strong) UIImage *defaultNavigationBarBackgroundImage;\n@property (nonatomic,copy) NSDictionary *defaultNavigationTitleTextAttributes;\n\n```\n\n### Memory leak detection\nto 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.\n![](https://github.com/Roen-Ro/DemoResources/blob/master/RRUIViewControllerExtensio/screen001.jpeg?raw=true)\n\nyou 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`\n\n```objective-c\n//Unavailable in release mode. \\\nin debug mode, defalut is NO for classes returned from +memoryLeakDetectionExcludedClasses method and YES for others\n@property (nonatomic,getter = memoryLeakDetectionEnabled) BOOL enabledMemoryLeakDetection;\n\n//read and add or remove values from the returned set to change default excluded memory detection classes\n+(NSMutableSet\u003cNSString *\u003e *)memoryLeakDetectionExcludedClasses;\n\n//for subclass to override\n-(void)didReceiveMemoryLeakWarning;\n\n```\n\n\n### viewController life cylcle hook\nhook 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:\n\n```objective-c\n\n//log the user enter page behavior\n[UIViewController hookLifecycle:RRViewControllerLifeCycleViewWillAppear\n                       onTiming:RRMethodInsertTimingBefore\n                      withBlock:^(UIViewController * _Nonnull viewController, BOOL animated) {\n\n                        [MyLog logEnterPage:NSStringFromClass([viewController class])];\n                    }];\n            \n            \n//log the user leaving page behavior\n[UIViewController hookLifecycle:RRViewControllerLifeCycleViewDidDisappear\n                       onTiming:RRMethodInsertTimingAfter\n                      withBlock:^(UIViewController * _Nonnull viewController, BOOL animated) {\n\n                        [MyLog logLeavePage:NSStringFromClass([viewController class])];\n                    }];\n\n```\n\n## Installation\n\nTo install using [CocoaPods](https://github.com/cocoapods/cocoapods), add the following to your project Podfile:\n\n```ruby\npod 'RRViewControllerExtension'\n```\nand in your project file importing by:\n```objective-c\n#import \u003cRRViewControllerExtension.h\u003e\n```\n\n\nAlternatively, drag and drop RRViewControllerExtension directory from [this code project](https://github.com/Roen-Ro/RRViewControllerExtension) into your Xcode project, importing files by:\n\n```objective-c\n#import \"RRViewControllerExtension.h\"\n```\n\n## TODO\nfix bug\nHide navigation back arrow after reset the stack by: `-[UINavigationController setViewControllers:]`\n\n## Author\n\nRoen (罗亮富), zxllf23@163.com\n\n## Licenses\n\nAll source code is licensed under the MIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froen-ro%2Frrviewcontrollerextension","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froen-ro%2Frrviewcontrollerextension","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froen-ro%2Frrviewcontrollerextension/lists"}