mirror of
https://github.com/zhigang1992/ECSlidingViewController.git
synced 2026-06-12 08:05:23 +08:00
1 line
6.8 KiB
JSON
1 line
6.8 KiB
JSON
{"google":"","note":"Don't delete this file! It's used internally to help with page regeneration.","body":"# ECSlidingViewController\r\n\r\n`ECSlidingViewController` is a view controller container for iOS that presents its child view controllers in two layers. It provides functionality for sliding the top view to reveal the views underneath it. This functionality is inspired by the Path 2.0 and Facebook iPhone apps.\r\n\r\n<iframe src=\"http://player.vimeo.com/video/35959384?title=0&byline=0&portrait=0\" width=\"400\" height=\"300\" frameborder=\"0\" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe><p><a href=\"http://vimeo.com/35959384\">ECSlidingViewController Demo</a> from <a href=\"http://vimeo.com/user5026288\">EdgeCase</a> on <a href=\"http://vimeo.com\">Vimeo</a>.</p>\r\n\r\nThis project is an example app that showcases the uses for `ECSlidingViewController`. This app uses storyboards, but it is not required.\r\n\r\n\r\n## Features\r\n\r\n* Panning gesture to move top view can be set on any `UIView`. It is most likely a navigation bar or the whole top view itself.\r\n* Configurable anchor positions, with automatic adjustments for orientation change. See \"Anchor Position Geometry\" section below.\r\n* There are no assumptions about the size and layout of the views under the top view. See the `underLeftWidthLayout` and `underRightWidthLayout` properties if you need a common layout.\r\n* The child views can be changed at anytime.\r\n* Child view controllers can be an instance of `UIViewController` or any subclass of `UIViewController` including `UINavigationController` and `UITabBarController`.\r\n* iPad support.\r\n* See [ECSlidingViewController/Vendor/ECSlidingViewController/ECSlidingViewController.h](https://github.com/edgecase/ECSlidingViewController/blob/master/ECSlidingViewController/Vendor/ECSlidingViewController/ECSlidingViewController.h) for options and configuration.\r\n\r\n## Requirements\r\n\r\n* iOS 5\r\n* ARC\r\n\r\n## Getting Started\r\n\r\nThis section will walk through of a simplified version of the included example app. You'll see how to setup the top view that can be panned to the right side to reveal the under left view.\r\n\r\n### Copy ECSlidingViewController into your project\r\n\r\nYou'll need these four files:\r\n\r\n* ECSlidingViewController/Vendor/ECSlidingViewController/ECSlidingViewController.h\r\n* ECSlidingViewController/Vendor/ECSlidingViewController/ECSlidingViewController.m\r\n* ECSlidingViewController/Vendor/ECSlidingViewController/UIImage+ImageWithUIView.h\r\n* ECSlidingViewController/Vendor/ECSlidingViewController/UIImage+ImageWithUIView.m\r\n\r\n### Setup storyboards and set the topViewController\r\n\r\nAdd a UIViewController to your storyboards and set the subclass to `ECSlidingViewController`. Then, you'll need to configure the instance of this view controller by setting a `topViewController`\r\n\r\n\t ECSlidingViewController *slidingViewController = (ECSlidingViewController *)self.window.rootViewController;\r\n\t \r\n\t slidingViewController.topViewController = [self.storyboard instantiateViewControllerWithIdentifier:@\"FirstTop\"];\r\n\r\nIn this example, we can get a reference to the `ECSlidingViewController` instance then, we set the `topViewController` with an instance of a `UIViewController` subclass called `FirstTopViewController` that is identified as \"FirstTop\".\r\n\r\n### Configure the topViewController\r\n\r\nThe top view controller is responsible for two things:\r\n\r\n* Setting the view controllers underneath it.\r\n* Adding the `panGesture` to a `UIView`.\r\n\r\nTo do these, you must first add an `#import \"ECSlidingViewController.h\"` to the `FirstTopViewController` header. Then in the implementation you'll have access to a category on `UIViewController` called `slidingViewController`. This the top-level instance of the `ECSlidingViewController` container. With this instance, you can set the view controllers underneath the top view and add panning.\r\n\r\nBelow is the `viewWillAppear:` method for `FirstTopViewController`.\r\n\r\n\t- (void)viewWillAppear:(BOOL)animated\r\n\t{\r\n\t [super viewWillAppear:animated];\r\n\t \r\n\t if (![self.slidingViewController.underLeftViewController isKindOfClass:[MenuViewController class]]) {\r\n\t self.slidingViewController.underLeftViewController = [self.storyboard instantiateViewControllerWithIdentifier:@\"Menu\"];\r\n\t }\r\n\t \r\n\t [self.view addGestureRecognizer:self.slidingViewController.panGesture];\r\n\t [self.slidingViewController setAnchorRightRevealAmount:280.0f];\r\n\t}\r\n\r\nThe above code will conditionally set the `underLeftViewController` if it is not already there. Then, it adds the gesture recognizer to the top view. The last line of code specifies the top view's anchor position on the right side.\r\n\r\n## Anchor Position Geometry\r\n\r\nThere are four properties related to anchor positions. They are a combination of left, right, reveal amount, and peek amount. The diagrams below demonstrate the difference between peek and reveal.\r\n\r\n* anchorLeftPeekAmount\r\n* anchorRightPeekAmount\r\n* anchorLeftRevealAmount\r\n* anchorRightRevealAmount\r\n\r\nBelow is an example of the anchorRightPeekAmount set:\r\n\r\n\r\n\r\nBelow is an example of the anchorRightRevealAmount set:\r\n\r\n\r\n\r\n## MIT License\r\nCopyright (C) 2012 EdgeCase\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy of\r\nthis software and associated documentation files (the \"Software\"), to deal in\r\nthe Software without restriction, including without limitation the rights to\r\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\r\nof the Software, and to permit persons to whom the Software is furnished to do\r\nso, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\nSOFTWARE.","name":"ECSlidingViewController","tagline":"ECSlidingViewController is a view controller container for iOS that presents its child view controllers in two layers. It provides functionality for sliding the top view to reveal the views underneath it. This functionality is inspired by the Path 2.0 and Facebook iPhone apps."} |