GithubHelp home page GithubHelp logo

jsooriah / flicktodismiss Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jakelawson1/flicktodismiss

0.0 1.0 0.0 2.16 MB

A basic UIViewController class that presents a UIView which can be dismissed by flicking it off the screen.

License: MIT License

Swift 100.00%

flicktodismiss's Introduction

FlickToDismiss

FlickToDismiss hero image

Requirements

  • iOS 8.0+
  • Xcode 7.3

Installation

Manual

Add FlickToDismissViewController.swift to your project in Xcode.

Usage

Interface Builder

  1. Drag a new UIViewController object onto your storyboard.
  2. Set the class to FlickToDismissViewController.
  3. Drag a UIView object onto the View Controller.
  4. Add any necessary constraints.
  5. Connect the flickableView outlet to the UIView in the Connections inspector.
  6. Job done.

Programatically

let viewToFlick = UIView(frame: CGRect(x: 0, y: 0, width: 280, height: 300))
viewToFlick.backgroundColor = .whiteColor()
// Optional - See FlickToDismissOption for available options.
let options: [FlickToDismissOption] = [
.Animation(.Scale),
.BackgroundColor(UIColor(white: 0.0, alpha: 0.8))
]
let vc = FlickToDismissViewController(flickableView: viewToFlick, options: options)
vc.modalTransitionStyle = .CrossDissolve
vc.modalPresentationStyle = .OverFullScreen
presentViewController(vc, animated: true, completion: nil)

Hint - Subclassing UIView

Since Auto Layout sizes views according to their frames, it incorrectly assumes it has a larger space to lay things out when a view is rotated. To correct this we need to supply the method alignmentRectForFrame() in the view subclass:

override func alignmentRectForFrame(frame: CGRect) -> CGRect {
    return bounds
}

License

FlickToDismiss is licensed under the MIT License. See LICENSE for details.

Let me know if you use FlickToDismiss in your projects, I would love to know!

flicktodismiss's People

Contributors

jakelawson1 avatar

Watchers

 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.