-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ryan Nystrom
committed
Mar 10, 2018
1 parent
db60900
commit 48faf36
Showing
4 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,82 @@ | ||
COMING SOON | ||
<p align="center"> | ||
<img src="/images/animation.gif" /> | ||
</p> | ||
|
||
## Installation | ||
|
||
Just add `ContextMenu` to your Podfile and `pod install`. Done! | ||
|
||
```ruby | ||
pod 'ContextMenu' | ||
``` | ||
|
||
## Usage | ||
|
||
Show the menu from one of your `UIViewController`s: | ||
|
||
```swift | ||
ContextMenu.shared.show( | ||
sourceViewController: self, | ||
viewController: MyContentViewController() | ||
) | ||
``` | ||
|
||
You must provide a custom `UIViewController` to display in the menu. The only requirement is that you must set `preferredContentSize` to size your content. | ||
|
||
```swift | ||
class MyContentViewController: UIViewController { | ||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
title = "Demo" | ||
preferredContentSize = CGSize(width: 200, height: 200) | ||
} | ||
} | ||
``` | ||
|
||
<img src="/images/basic.png" /> | ||
|
||
## Customizations | ||
|
||
### Display from a Source View | ||
|
||
Animate the menu out from a button or view. `ContextMenu` will take care of layout so that your menu doesn't clip the screen. | ||
|
||
``` | ||
@IBAction func onButton(_ sender: UIButton) { | ||
ContextMenu.shared.show( | ||
sourceViewController: self, | ||
viewController: MyContentViewController(), | ||
sourceView: sender | ||
) | ||
} | ||
``` | ||
|
||
### Container Style & Display | ||
|
||
Use `ContextMenu.Options` to change the appearance of the containing view. | ||
|
||
```swift | ||
ContextMenu.shared.show( | ||
sourceViewController: self, | ||
viewController: MenuViewController(), | ||
options: ContextMenu.Options(containerStyle: ContextMenu.ContainerStyle(backgroundColor: .blue)), | ||
sourceView: button | ||
) | ||
``` | ||
|
||
<img src="/images/blue.png" /> | ||
|
||
There's plenty more you can customize with `ContextMenu.ContainerStyle`: | ||
|
||
- `cornerRadius`: The corner radius of the menu | ||
- `shadowRadius` and `shadowOpacity`: Appearance of the container shadow | ||
- `xPadding`, `yPadding`, `edgePadding`: Padding from the source view and screen edge | ||
- `overlayColor`: The color of the background | ||
- `motionEffect`: Respond to device gyroscope changes, similar to app icons on Springboard.app. | ||
|
||
If you want more customizations, we will gladly accept a Pull Request! | ||
|
||
## Acknowledgements | ||
|
||
- Heavy inspiration from [SlackTextViewController](https://github.com/slackhq/SlackTextViewController) | ||
- Created with ❤️ by [Ryan Nystrom](https://twitter.com/_ryannystrom) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.