• Stars
    star
    114
  • Rank 298,043 (Top 7 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created about 11 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A UIViewController which take a root view controller and present it modally with a nice animation

DMCustomModalViewController

DMCustomModalViewController is a UIViewController subclass which take a root view controller and present it modally with a nice animation (a la gmail).

You should not subclass it, it act as a container view controller that you can directly instantiate and use.

For iOS 7 and later

##Features

DMCustomModalViewController provide a quick and an easy solution to display modal view controller with a nice animation. It have an option to display the modal view controller not full screen and keeping the current view controller in the background with a nice overlay on it.

  1. 2 ways of presenting it, fullscreen or not full screen.
  2. Nice animations!
  3. Keep the current context and display the view in background and add an onverlay on it.
  4. More to come.

##How to use it

TL;DR: Look at the example provided.

###Cocoapods

Add pod DMCustomModalViewController to your podfile

###Run the example and install it manually

Run pod installin the example folder

  1. Add DMCustomModalViewController.h and .m from the classes/ folder to your Xcode project.
  2. Add QuartzCore.framework to "Link Binary With Libraries" (.xcodeproj -> Build Phases)
  3. Import DMCustomModalViewController.hwhere you want to use it.

###Full Screen

ModalRootViewController *root = [[ModalRootViewController alloc]initWithNibName:nil bundle:nil];
_fullScreenModal = [[DMCustomModalViewController alloc]initWithRootViewController:root
                                                                               parentViewController:self];
[self.fullScreenModal setDelegate:self];
[self.fullScreenModal presentRootViewControllerWithPresentationStyle:DMCUstomModalViewControllerPresentFullScreen controllercompletion:^{
    
}];

###Part screen

image

ModalRootViewController *root = [[ModalRootViewController alloc]initWithNibName:nil bundle:nil];
_partModal = [[DMCustomModalViewController alloc]initWithRootViewController:root
                                                                               parentViewController:self];
[self.partModal setDelegate:self];
self.partModal.rootViewControllerHeight = 350;
[self.partModal presentRootViewControllerWithPresentationStyle:DMCustomModalViewControllerPresentPartScreen controllercompletion:^{
    
}];

If you are not presenting it fullscreen you need to set the rootViewControllerHeight property. This value will be used to know how much of your rootViewController need to be displayed

###Dismiss DMCustomModalViewController provide a built in category, just import the .h of DMCustomModalViewController in your rootViewController you passed to the instance of DMCustomModalViewController, you will have access to a new property customModalViewController. You can then freely dismiss the modal from itself.

[self.customModalViewController dismissRootViewControllerWithcompletion:^{

}];

A better implementation would be to build yourself some delegate for your rootViewController, so the controller which fired the modal would be also responsible for dismissing it.

###Delegate

DMCustomViewController currently provide one delegate method to inform you when it was dismissed.

@protocol DMCustomViewControllerDelegate <NSObject>
@optional
- (void)customModalViewControllerDidDismiss:(DMCustomModalViewController *)modalViewController;
@end

###Customization You can customize the animation speed by setting the property CGFloat animationSpeed before presenting the modal view controller The default value is 0.30

You can also customize the scaling of the parent controller view when the modal view is presented. It will affect the recoil effect. For that modify the property CGFloat parentViewScaling the default value is 0.80.

Also by default when you tap on the parent view when the modal is not presented full screen it will close it, you can turn it off by setting tapParentViewToClose to NO.

If you rootViewController view have a navigation bar you'll be able to drag the navigation bar if dragRootViewNavigationBar is set to YES (by default it is set to YES). Work only when the modal view is not presented full screen.

There are some other properties for you to play with.

The example provide sliders on the UI to better understand the effect of each property. Just run it in the simulator :)

Licensing

Copyright (C) 2013 by Thomas Ricouard.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

MovieSwiftUI

SwiftUI & Combine app using MovieDB API. With a custom Flux (Redux) implementation.
Swift
6,369
star
2

IceCubesApp

A SwiftUI Mastodon client
Swift
4,506
star
3

RedditOS

The product name is Curiosity, a SwiftUI Reddit client for macOS Big Sur
Swift
3,915
star
4

SwiftHN

A Hacker News reader in Swift
Swift
1,707
star
5

ACHNBrowserUI

Animal Crossing New Horizon companion app in SwiftUI
Swift
1,654
star
6

SwiftUIFlux

A very naive implementation of Redux using Combine BindableObject to serve as an example
Swift
646
star
7

MortyUI

A very simple Rick & Morty app to demo GraphQL + SwiftUI
Swift
461
star
8

HackerSwifter

A Swift Hacker News library
Swift
170
star
9

DMCustomTransitions

Some custom transitions for iOS 7
Objective-C
94
star
10

MovieSwiftUI2

A complete reinvention
Swift
64
star
11

RunewordsApp

A SwiftUI app to filter & search runewords for Diablo II
Swift
58
star
12

The-Roundtable

An Elden Ring companion app using SwiftUI + GraphQL
Swift
48
star
13

DMFilterView

A UIView Subclass which add itself at the bottom of any view.
Objective-C
39
star
14

OSRSUI

Old School Runescape database browser in SwiftUI
Swift
35
star
15

SwiftUIDemo

SwiftUI + Redux
Swift
35
star
16

Sublime-Hacker-News-Reader

Read Hacker News front page right from Sublime Text.
Python
24
star
17

SwiftUIKit

A package with the missing SwiftUI components
Swift
21
star
18

PopupViewController

UIViewController drop in replacement with much more customisation
Swift
21
star
19

DMSocialContactsList

An objective-c contacts picker example which fetch local and Facebook contacts, merge and sort them. Plus handle selection. Useful to send SMS, Email, Facebook invitation.
Objective-C
19
star
20

Musix

A macOS Apple Music client using MusicKit
Swift
17
star
21

DMRESTRequest-objc

Super simple objective-c REST request wrapper.
Objective-C
14
star
22

PocketSwiftUI

Pocket SwiftUI: Learn and practice SwiftUI on the go
14
star
23

icecubesweb

Experimental SwiftUI app for the web
Swift
12
star
24

LittleOrion

Master of Orion like for your iOS devices, for now it's mostly nothing...
Swift
12
star
25

SwiftTests

Swift
10
star
26

CryptoTickerSwiftUI

A SwiftUI crypto ticker (show latest transactions) on the CoinbasePro/GDAX socket API
Swift
8
star
27

DMGesturedNavigationController

Objective-C
8
star
28

Date-ACNHEvents

Swift
7
star
29

OSRSUIGraphQL

A GraphQL Old School RuneScape + SwiftUI helper app
Swift
6
star
30

GrailerApp

A Diablo 2 app to track your items and much, much more
Swift
6
star
31

FrenchKitSwiftUIClassroom

Swift
5
star
32

dimillian

4
star
33

pico8-suvivor

A vampire survivor clone for pico-8
C
3
star
34

NotesCards

Swift
3
star
35

dimillian.github.io

HTML
3
star
36

iOS-ReactHN

An Hacker News reader built with React Native
3
star
37

GDAXTicker

A GDAX Ticker in Swift
Swift
3
star
38

dimillian.app

dimillian.app website
MDX
2
star
39

PTCGCollector

An app to collect & browse your Pokemon Trading Card collection
2
star
40

TronCycle

A Tron inspired game in Swift.
Swift
2
star
41

vCard

My personal website at http://thomasricouard.info
CSS
2
star
42

Galaxy-Traders

1
star
43

Blog

My new Blog powered by Hugo
Shell
1
star
44

rSDK

Raven SDK
Objective-C
1
star
45

Raven-For-Mac

Raven Browser
Objective-C
1
star
46

PicSpeak

Something cool
1
star
47

iOSReduxBoilerplate

iOS Redux app example
1
star
48

folio

New folio in react
TypeScript
1
star
49

McReddit

Swift
1
star
50

No-Name

Something in Swift to play with.
1
star
51

PopApp

TBD
Swift
1
star
52

blog-articles

Articles of http://blog.thomasricouard.info
1
star
53

objective-c-stuff

Various stuff
Objective-C
1
star