{"id":2559,"url":"https://github.com/ruslanskorb/RSKKeyboardAnimationObserver","last_synced_at":"2025-08-03T00:31:56.319Z","repository":{"id":62452200,"uuid":"46512150","full_name":"ruslanskorb/RSKKeyboardAnimationObserver","owner":"ruslanskorb","description":"Showing / dismissing keyboard animation in simple UIViewController category.","archived":true,"fork":false,"pushed_at":"2015-11-19T18:49:13.000Z","size":45,"stargazers_count":45,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-16T04:31:21.970Z","etag":null,"topics":["animation","hide","keyboard","show"],"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/ruslanskorb.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}},"created_at":"2015-11-19T18:32:28.000Z","updated_at":"2023-01-28T18:02:08.000Z","dependencies_parsed_at":"2022-11-01T23:45:36.433Z","dependency_job_id":null,"html_url":"https://github.com/ruslanskorb/RSKKeyboardAnimationObserver","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruslanskorb%2FRSKKeyboardAnimationObserver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruslanskorb%2FRSKKeyboardAnimationObserver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruslanskorb%2FRSKKeyboardAnimationObserver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruslanskorb%2FRSKKeyboardAnimationObserver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ruslanskorb","download_url":"https://codeload.github.com/ruslanskorb/RSKKeyboardAnimationObserver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228510718,"owners_count":17931756,"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":["animation","hide","keyboard","show"],"created_at":"2024-01-05T20:16:16.872Z","updated_at":"2024-12-06T18:30:32.315Z","avatar_url":"https://github.com/ruslanskorb.png","language":"Objective-C","funding_links":[],"categories":["UI"],"sub_categories":["Keyboard","Other free courses"],"readme":"## RSKKeyboardAnimationObserver ![License](http://img.shields.io/badge/license-MIT-green.svg?style=flat) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/ruslanskorb/RSKKeyboardAnimationObserver)\r\n\r\nEasy way to handle iOS keyboard showing/dismissing. \r\n\r\n## Introduction\r\nWorking with iOS keyboard demands a lot of duplicated code. This category allows you to declare your animations with smooth keyboard animation timing while writing very little code.\r\n\r\n## Demo\r\n![KeyboardAnimationDemo1](https://raw.githubusercontent.com/Just-/demo/master/an_kb_animation_demo.gif)\r\n![KeyboardAnimationDemo2](https://raw.githubusercontent.com/Just-/demo/master/kb_anim_demo.gif)\r\n\r\n## Installation\r\n*RSKKeyboardAnimationObserver requires iOS 6.0 or later.*\r\n\r\n### Using [CocoaPods](http://cocoapods.org)\r\n\r\n1.  Add the pod `RSKKeyboardAnimationObserver` to your [Podfile](http://guides.cocoapods.org/using/the-podfile.html).\r\n\r\n        pod 'RSKKeyboardAnimationObserver'\r\n\r\n2.  Run `pod install` from Terminal, then open your app's `.xcworkspace` file to launch Xcode.\r\n3.  Import the `RSKKeyboardAnimationObserver.h` header. Typically, this should be written as `#import \u003cRSKKeyboardAnimationObserver/RSKKeyboardAnimationObserver.h\u003e`\r\n\r\n### Using [Carthage](https://github.com/Carthage/Carthage)\r\n\r\n1.  Add the `ruslanskorb/RSKKeyboardAnimationObserver` project to your [Cartfile](https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#cartfile).\r\n\r\n        github \"ruslanskorb/RSKKeyboardAnimationObserver\"\r\n\r\n2.  Run `carthage update`, then follow the [additional steps required](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application) to add the iOS and/or Mac frameworks into your project.\r\n3.  Import the RSKKeyboardAnimationObserver framework/module.\r\n    *  Using Modules: `@import RSKKeyboardAnimationObserver`\r\n    *  Without Modules: `#import \u003cRSKKeyboardAnimationObserver/RSKKeyboardAnimationObserver.h\u003e`\r\n\r\n## Example\r\nImagine that you need to implement chat-like input over keyboard. OK, import this category.\r\n\r\n``` objective-c\r\n#import \u003cRSKKeyboardAnimationObserver/RSKKeyboardAnimationObserver.h\u003e\r\n```\r\n\r\nThen make autolayout constraint between your input bottom and superview botton in *Interface Builder*, connect it with your view controller implementation through *IBOutlet*.\r\n\r\n``` objective-c\r\n@property (weak, nonatomic) IBOutlet NSLayoutConstraint *chatInputBottomSpace;\r\n```\r\n\r\nThen subscribe to keyboard in the place you like (**viewDidAppear** is the best place really).\r\n\r\n``` objective-c\r\n__weak typeof(self) weakSelf = self;\r\n[self rsk_subscribeKeyboardWithWillShowOrHideAnimation:^(CGRect keyboardRectEnd, NSTimeInterval duration, BOOL isShowing) {\r\n    __strong typeof(self) strongSelf = weakSelf;\r\n    if (strongSelf) {\r\n        strongSelf.chatInputBottomSpace.constant = isShowing ?  CGRectGetHeight(keyboardRectEnd) : 0;\r\n        [strongSelf.view layoutIfNeeded];\r\n    }\r\n} onComplete:nil];\r\n```\r\n\r\nThat’s all! \r\n\r\n**Don’t forget** to unsubscribe from keyboard events (**viewDidDisappear** is my recommendation). Calling this category method will do all the “dirty” work for you.\r\n\r\n    [self rsk_unsubscribeKeyboard];\r\n\r\nFor more complex behaviour (like in demo section) you can use extended API call with **before animation** section.\r\n\r\n``` objective-c\r\n__weak typeof(self) weakSelf = self;\r\n[self rsk_subscribeKeyboardWithBeforeWillShowOrHideAnimation:^(CGRect keyboardRectEnd, NSTimeInterval duration, BOOL isShowing) {\r\n    __strong typeof(self) strongSelf = weakSelf;\r\n    if (strongSelf) {\r\n        strongSelf.isKeaboardAnimation = YES;\r\n        \r\n        [UIView transitionWithView:strongSelf.imageView duration:duration options:UIViewAnimationOptionTransitionCrossDissolve animations:^{\r\n            if (isShowing) {\r\n                strongSelf.imageView.image = [strongSelf.imageView.image applyLightEffect];\r\n            } else {\r\n                [strongSelf.imageView hnk_setImageFromURL:strongSelf.model.cardImageUrl];\r\n            }\r\n        } completion:nil];\r\n    }\r\n } willShowOrHideAnimation:^(CGRect keyboardRectEnd, NSTimeInterval duration, BOOL isShowing) {\r\n    __strong typeof(self) strongSelf = weakSelf;\r\n    if (strongSelf) {\r\n        strongSelf.headerHeight.constant = isShowing ? kHeaderMinHeight : kHeaderMaxHeight;\r\n        strongSelf.panelSpace.constant = isShowing ?  CGRectGetHeight(keyboardRectEnd) : 0;\r\n        \r\n        for (UIView *v in strongSelf.headerAlphaViews) {\r\n            v.alpha = isShowing ? 0.0f : 1.0f;\r\n        }\r\n\r\n        [strongSelf.view layoutIfNeeded];\r\n    }\r\n} onComplete:^(BOOL finished, BOOL isShown) {\r\n    __strong typeof(self) strongSelf = weakSelf;\r\n    if (strongSelf) {\r\n        strongSelf.isKeaboardAnimation = NO;\r\n    }\r\n}];\r\n```\r\n\r\n## Contact\r\n\r\nRuslan Skorb\r\n\r\n- http://github.com/ruslanskorb\r\n- http://twitter.com/ruslanskorb\r\n- ruslan.skorb@gmail.com\r\n\r\n## License\r\n\r\nThis project is is available under the MIT license. See the LICENSE file for more info. Attribution by linking to the [project page](https://github.com/ruslanskorb/RSKKeyboardAnimationObserver) is appreciated.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruslanskorb%2FRSKKeyboardAnimationObserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fruslanskorb%2FRSKKeyboardAnimationObserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruslanskorb%2FRSKKeyboardAnimationObserver/lists"}