Giter Club home page Giter Club logo

modalcontroller's Introduction

ModalController

Modal for iOS 8

Simplest Usage

let modal = ModalController()
modal.contentMake(wid: 300.0, hgt: 300.0, bgColor: UIColor.blackColor(), cornerRad: 15)
presentViewController(modal, animated: true, completion: nil)
Custom View

You can alternatively assign a custom content view instead of using the convenient contentMake function

...
let modal = ModalController()
modal.content = myCustomView
presentViewController(modal, animated: true, completion: nil)

Customize Content View

let modal = ModalController()
modal.contentMake(wid: 300.0, hgt: 300.0, bgColor: UIColor.whiteColor(), cornerRad: 15)
/* Start Customizations */
let label = UILabel(frame: modal.content.bounds)
label.text = "Hello World"
modal.content.addSubview(label)
/* End Customizations */
presentViewController(modal, animated: true, completion: nil)

Customize Tap To Close

let modal = ModalController()
modal.contentMake(wid: 300.0, hgt: 300.0, bgColor: UIColor.blackColor(), cornerRad: 15)
/* Start Customizations */
modal.closeOnContentTap = true
modal.closeOnBGTap = false
/* End Customizations */
presentViewController(modal, animated: true, completion: nil)

Customize transparent dark background

modal.backgroundDarkness = 0.4

Fine-grain control

modal.onClose = { ()->Void in
    // perform close logic before modal gets dismissed
}

modal.onCloseCompletion = { ()->Void in
    // perform close logic after modal gets dismissed
}

modal.onViewDidLayoutSubviews = { (modalBGView,contentView)->Void in
    contentView.frame = CGRect(x: 0, y: 0, width: modalBGView.frame.size.width, height: modalBGView.frame.size.height/2)
}

Use storyboard

Assign the @IBOutlet in ModalController.swift:

@IBOutlet var content: UIView!

Hello World Example used in screenshot

let modal = ModalController()
modal.contentMake(wid: 300.0, hgt: 300.0, bgColor: UIColor.whiteColor(), cornerRad: 15)
let label = UILabel(frame: modal.content.bounds)
label.text = "Hello World"
label.textAlignment = .Center
label.font = UIFont.systemFontOfSize(30)
modal.content.addSubview(label)
presentViewController(modal, animated: true, completion: nil)

modalcontroller's People

Contributors

koreyhinton avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  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.