Latest 1.1
Homepage https://github.com/georgetso/HalfPresentationAnimation
License MIT
Platforms ios 8.0, requires ARC
Frameworks UIKit

Language: Swift 2.x

Present model view controller in half its height. Useful when a contextual operation is needed like password input, user confirmation, etc.

IMPORTANT: tested in iPhone iOS8 and above only, portrait supported only.

Welcome to contribute to iPad test, rotation support and size classes support.


Screen Shot

Screent Shot


Installation

CocoaPods

pod 'HalfPresentationAnimation'

Usage

  1. You will need to conform to and implements HalfPresentable protocol in your UIViewController SubClass
  2. To present a view controller, use code like this:

    func present() {
        let vc = YourViewController()
        vc.title = "My Title"
        vc.delegate = self          // user action communication
        vc.transitioningDelegate = self     // important line
        vc.modalPresentationStyle = .Custom // important line
        presentViewController(vc, animated: true, completion: nil)
    }

Notice

  1. Usually you create a navigation controller to present, but whatever.
  2. The presented view controller red one in above image shows half height, but it actually has a full height. So if you want to center a button, button.center = CGPointMake(view.center.x, view.center.y/2).

Customization

Parameters are not exposed, you can modify the source file, however. You can also add motion effect on background view controller if you like.

Problem

You will have to set transitioningDelegate to a UIViewController SubClass instance, not other objects like view models.

Latest podspec

{
    "name": "HalfPresentationAnimation",
    "version": "1.1",
    "summary": "Half presenting a view controller for contextual interaction.",
    "description": "Half presenting a view controller for contextual interaction in Swift 2.x",
    "homepage": "https://github.com/georgetso/HalfPresentationAnimation",
    "license": "MIT",
    "authors": "George Tso",
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/georgetso/HalfPresentationAnimation.git",
        "tag": "1.1"
    },
    "source_files": "HalfPresentationAnimation/*.swift",
    "frameworks": "UIKit",
    "requires_arc": true
}

Pin It on Pinterest

Share This