Giter Site home page Giter Site logo

senthilece01 / contextmenu Goto Github PK

View Code? Open in Web Editor NEW

This project forked from githawkapp/contextmenu

0.0 2.0 0.0 186 KB

An iOS context menu UI inspired by Things 3.

Home Page: http://githawk.com/

License: MIT License

Ruby 1.99% Swift 96.43% Objective-C 1.57%

contextmenu's Introduction

  • Contextual menus with delightful animations and styles
  • Total control over menu contents using your own UIViewControllers
  • Tons of feature and interaction customizations

Installation

Just add ContextMenu to your Podfile and pod install. Done!

pod 'ContextMenu'

For Carthage, just add GitHawkApp/ContextMenu to your Cartfile and carthage bootstrap.

github "GitHawkApp/ContextMenu"

Usage

Show the menu from one of your UIViewControllers:

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.

class MyContentViewController: UIViewController {
  override func viewDidLoad() {
    super.viewDidLoad()
    title = "Demo"
    preferredContentSize = CGSize(width: 200, height: 200)
  }
}

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.

ContextMenu.shared.show(
  sourceViewController: self,
  viewController: MenuViewController(),
  options: ContextMenu.Options(containerStyle: ContextMenu.ContainerStyle(backgroundColor: .blue)),
  sourceView: button
)

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

contextmenu's People

Contributors

rnystrom avatar basthomas avatar kidap avatar marcuswu0814 avatar wickwirew avatar

Watchers

James Cloos avatar Senthil_Kumar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.