Giter VIP home page Giter VIP logo

kgmodal's Introduction

KGModal is an easy drop in control that allows you to display any view in a modal popup. The modal will automatically scale to fit the content view and center it on screen with nice animations!

You supply your own content view and KGModal does the rest:

[[KGModal sharedInstance] showWithContentView:contentView andAnimated:YES];

There are a couple other options but it's purposely designed to be simple and easy to use:

// Determines if the modal should dismiss if the user taps outside of the modal view
// Defaults to YES
@property (nonatomic) BOOL tapOutsideToDismiss;

// Determines if the close button or tapping outside the modal should animate the dismissal
// Defaults to YES
@property (nonatomic) BOOL animateWhenDismissed;

// Determins close button type (None/Left/Right)
// Defaults to Left
@property (nonatomic) KGModalCloseButtonType closeButtonType;

// Determines whether close button will display on the left or right
// Defaults to left
@property (nonatomic) KGModalCloseButtonLocation closeButtonLocation;

// The background color of the modal window
// Defaults black with 0.5 opacity
@property (strong, nonatomic) UIColor *modalBackgroundColor;

// The background display style, can be a transparent radial gradient or a transparent black
// Defaults to gradient, this looks better but takes a bit more time to display on the retina iPad
@property (nonatomic) enum KGModalBackgroundDisplayStyle backgroundDisplayStyle;

// The shared instance of the modal
+ (id)sharedInstance;

// Set the content view to display in the modal and display with animations
- (void)showWithContentView:(UIView *)contentView;

// Set the content view to display in the modal and whether the modal should animate in
- (void)showWithContentView:(UIView *)contentView andAnimated:(BOOL)animated;

// Hide the modal with animations
- (void)hide;

// Hide the modal with animations,
// run the completion after the modal is hidden
- (void)hideWithCompletionBlock:(void(^)())completion;

// Hide the modal and whether the modal should animate away
- (void)hideAnimated:(BOOL)animated;

// Hide the modal and whether the modal should animate away,
// run the completion after the modal is hidden
- (void)hideAnimated:(BOOL)animated withCompletionBlock:(void(^)())completion;

Check out the ExampleApp to see it in action!

###Installation via Cocoapods

Add pod 'KGModal', '~> 0.0.1' to your Podfile and run pod to install.

kgmodal's People

Contributors

ashikahmad avatar jurysch avatar kgn avatar kimar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kgmodal's Issues

Build error

Hi, kgn,

I really appreciate for sharing codes in advance.

Unfortunately, I am having building errors with XCode Version 4.4.1 (4F1003).

For more information of the top most error among many errors, the following code block give the error message saying "Type specifier missing, default to 'int' " in KGModal.h file.

NS_ENUM(NSUInteger, KGModalBackgroundDisplayStyle){
KGModalBackgroundDisplayStyleGradient,
KGModalBackgroundDisplayStyleSolid
};

Any idea?

I am looking forward to hearing from you.

Thanks much.

.a library and binding to MonoTouch framework

Hi I really like your control
congratulations!

I would like to binding this control for Xamarin Monotouch, there are problems for this?
I have some problem to generate .a library file, with Xcode can send it to me?

thanks
Cris

User Interaction disabled after alertview

If we display alertView on top of the KGModal from some other class and after dismiss of alert we can dismiss KGModal but the user interaction is disabled of the view controller from where we presented the KGModal.

Keyboard bug after dismiss a KGModal view

Hi @kgn ,

Just found a small bug when I was trying to display the Keyboard after dismiss the KGModal pop-up window.

How to reproduce this issue:

  1. Pop up a KGModal view.
  2. Dismiss that view
  3. Make a text input control(UITextField or UITextView) become the first responder.
  4. Try to click the "Dismiss" button in the UIKeyboard to dismiss the keyboard. Not work here. The keyboard will stuck in the screen.

I figure out this issue might cause by the cleanup method doesnt clean up very well.

In the original code, you just do like this:

    [self.window removeFromSuperview];
    self.window = nil;

I add few more line code in the KGModal.m file and solve this issue.

  1. Add new property called originalWindow.
  2. Add following code in to the show method
  self.originalWindow = [UIApplication sharedApplication].keyWindow;
  1. Add the following code into the cleanup method
[self.originalWindow makeKeyAndVisible];
[self.window endEditing:YES];
[self.window resignKeyWindow];
[self.window resignFirstResponder];
[self.window removeFromSuperview];

Done.

Sorry for not able to create a fork for this.

Thanks.

Cannot type into editable text field

I have an editable UITextField in my contentView. If I add this view to the main ViewController it's editable as expected.

If I add the view to the KGModal shared instance it will accept a mouse click and the cursor appears along with the keyboard, but I cannot type into the text field.

I have not been able to isolate the issue, but it appears to be, at least in part, because of something in the KGModal class.

Popup issue on iOS 13

My view is not showing up on iOS 13. iOS 11 working fine.

KGModal.sharedInstance()?.show(withContentView: self.myView)

Thanks in advance

Callback/notification of dismissal?

Is there any way of getting notified (or being able to run some code) when the KGModal is dismissed (either by tapping the close box or tapping outside of it)? Blocks, NSNotification, anything?

How to add UINavigationController?

Hi
Thanks for such a great control. Hope it would be one of the most useful control in my upcoming app. In my app, on almost every screen i need to display this kind of Modal. But i need to load UINavigationController in Modal Popup, so that further push/pop can work inside. But when i use
[[KGModal sharedInstance] showWithContentViewController:myNavigationController]
It opens it in full screen, with 'X' button almost out of screen.
So how this problem can be fixed?

iOS10, App will freeze when keyboard display on KGModal

Hi,
I have built my app on Xcode7 it work fine on iOS7,8,9 but iOS10.0.2 app will freeze, can not touch on any control in screen.
I am using KGModal -> added UITextfield, when touch on textfield the keyboard will display and then hide KGModal the app will freeze.
If I build app on Xcode8 the issue was solved. But my source need to build on Xcode7.

Please help me fix issue on Xcode7.

hideAnimated does return control to the caller

Hi,

I using your model code to view a UIViewController from a storyboard.

Within an action on the caller.

FooViewController *fooViewController =[[self storyboard] instantiateViewControllerWithIdentifier:@"Foo"];

fooViewController.view.bounds = CGRectMake(0, 0, 260, 400);
fooViewController.delegate = self;

[[KGModal sharedInstance] showWithContentViewController:fooViewController andAnimated:YES];

This all works, however closing of the KGModal does not return control to the caller UIViewController. The KGModal has disappeared, but none of the controls on the caller allow interactions. It is like the focus (first responder) is hidden or KGModal is still there but hidden.

Any ideas?

ARC issues

Please, check the XCode warnings, most of them are related to the weak properties.

Please add semantic version tags.

I’ve recently added KGModal to the CocoaPods package manager repo.

CocoaPods is a tool for managing dependencies for OS X and iOS Xcode projects and provides a central repository for iOS/OS X libraries. This makes adding libraries to a project and updating them extremely easy and it will help users to resolve dependencies of the libraries they use.

However, KGModal doesn't have any version tags. I’ve added the current HEAD as version 0.0.1, but a version tag will make dependency resolution much easier.

Semantic version tags (instead of plain commit hashes/revisions) allow for resolution of cross-dependencies.

In case you didn’t know this yet; you can tag the current HEAD as, for instance, version 1.0.0, like so:

$ git tag -a 1.0.0 -m "Tag release 1.0.0"
$ git push --tags

Please add iOS6 Autorotation Method to the KGModalViewController

In iOS6+, -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation is deprecated and replaced by: -(BOOL)shouldAutorotate.

If the new method could be added as follows, that would be very helpful...

- (BOOL)shouldAutorotate {
    return [[KGModal sharedInstance] shouldRotate];
}

Error compiling KGModal in an Objective C++ project: C++ forbids forward references to enum types

I get a semantic error when I try to compile KGModal in an Objective C++ project:
KGModal/KGModal.h:42:28: ISO C++ forbids forward references to 'enum' types

It seems to be due to the way KGModalBackgroundDisplayStyle is defined:

NS_ENUM(NSUInteger, KGModalBackgroundDisplayStyle){
KGModalBackgroundDisplayStyleGradient,
KGModalBackgroundDisplayStyleSolid
};

If I replace this with standard C++ enum definition:

enum KGModalBackgroundDisplayStyle
{
KGModalBackgroundDisplayStyleGradient,
KGModalBackgroundDisplayStyleSolid
};

Then my project compiles.

Rotating the KGModal

Hello,

First of all, Thank You for this wonderful control.

I am having the issues, where I need the KGModal to appar and rotate itself in an animation.

I am having issues with KGModalGradientView. I have tried to comment it out and found out that there's a problem in the CGContext.

I have successfully added the rotate animation with code:

 dispatch_async(dispatch_get_main_queue(), ^{
    [self.window makeKeyAndVisible];

    if(animated){
        viewController.styleView.alpha = 0;
        [UIView animateWithDuration:kFadeInAnimationDuration animations:^{
            viewController.styleView.alpha = 1;
        }];

        containerView.alpha = 0;
        containerView.layer.shouldRasterize = YES;
        containerView.layer.transform = CATransform3DScale(CATransform3DIdentity, 0.4, 0.4, 0.4);

        [UIView animateWithDuration:kTransformPart1AnimationDuration animations:^{
            containerView.alpha = 1;
            containerView.layer.transform = CATransform3DRotate(CATransform3DIdentity, M_PI , 0, 1, 0);
        } completion:^(BOOL finished) {

            containerView.layer.shouldRasterize = NO;
        }];

    }
});

Now the problem arise is when rotating something, half of the view is becoming gray and then it becomes normal.
image1
image2
image3

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.