Giter Site home page Giter Site logo

sweetalert-ios's Introduction

Sweet Alert iOS

Beautiful Animated custom Alert View inspired from javascript library SweetAlert. Written in Swift this SweetAlertView can be used in Swift and Objective-C projects. SweetAlertView provides live intutive experience to user actions.It can be used in place of UIAlertView and UIAlertController

###ScreenShots SweetAlert

###Usage #####Basic message:

SweetAlert().showAlert("Here's a message!")

#####Title with a text under:

SweetAlert().showAlert("Here's a message!", subTitle: "It's pretty, isn't it?", style: AlertStyle.None)

#####Animated Success message:

SweetAlert().showAlert("Good job!", subTitle: "You clicked the button!", style: AlertStyle.Success)

#####Warning message and Chained Animated Success messge on completion:

SweetAlert().showAlert("Are you sure?", subTitle: "You file will permanently delete!", style: AlertStyle.Warning, buttonTitle:"Cancel", buttonColor:UIColorFromRGB(0xD0D0D0) , otherButtonTitle:  "Yes, delete it!", otherButtonColor: UIColorFromRGB(0xDD6B55)) { (isOtherButton) -> Void in
            if isOtherButton == true {
            
                println("Cancel Button  Pressed")
            }
            else {
                SweetAlert().showAlert("Deleted!", subTitle: "Your imaginary file has been deleted!", style: AlertStyle.Success)
            }
}

#####Chained Alerts on actions with custom button colors:

//Chaining alerts with messages on button click
SweetAlert().showAlert("Are you sure?", subTitle: "You file will permanently delete!", style: AlertStyle.Warning, buttonTitle:"No, cancel plx!", buttonColor:UIColorFromRGB(0xD0D0D0) , otherButtonTitle:  "Yes, delete it!", otherButtonColor: UIColorFromRGB(0xDD6B55)) { (isOtherButton) -> Void in
            if isOtherButton == true {
                
                SweetAlert().showAlert("Cancelled!", subTitle: "Your imaginary file is safe", style: AlertStyle.Error)
            }
            else {
                SweetAlert().showAlert("Deleted!", subTitle: "Your imaginary file has been deleted!", style: AlertStyle.Success)
            }
}

#####Custom icon alert:

SweetAlert().showAlert("Sweet!", subTitle: "Here's a custom image.", style: AlertStyle.CustomImag(imageFile: "thumb.jpg"))

###Diffrent Animated Styles for Diffrent Purposes

enum AlertStyle {
    case Success,Error,Warning,None
    case CustomImag(imageFile:String)
}

###Installation Add the SwiftAlert.swift in to your project.

###Reuirements

  • Xcode 7.0+
  • iOS 7.0+

License

The MIT License (MIT)

Copyright (c) 2014 codestergit

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.

sweetalert-ios's People

Contributors

91haba avatar 9nix00 avatar chrisamanse avatar codestergit avatar mihailsalari avatar tiagomnh 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  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

sweetalert-ios's Issues

Support to Modal Segues

In the function showAlert isn't better to set the "window" (line 253) constant to "UIApplication.sharedApplication().keyWindow?.subviews.last"?

In my application, if I set the "keyWindow" to .first, the alert will be put in the back of a ViewController that is presented modally.

Objective-C project use problem

  • Objective-C programs are using SweetAlert.
  • After the update Xcode 8.3.2.
  • Xcode 2.3 is no longer compatible with Swift version 2.3.
  • then SweetAlert update for Swift grammar version 3.0.
  • In introducing SweetAlert Objectiv - C project, compiled generated Objective-C class
......

#if defined(__has_feature) && __has_feature(modules)
@import UIKit;
#endif

#pragma clang diagnostic ignored "-Wproperty-attribute-mismatch"
#pragma clang diagnostic ignored "-Wduplicate-method-arg"
@class NSCoder;
@class UIButton;
@class NSBundle;

SWIFT_CLASS("_TtC4demo10SweetAlert")
@interface SweetAlert : UIViewController
- (nonnull instancetype)init SWIFT_UNAVAILABLE;
- (nonnull instancetype)initWithCoder:(NSCoder * _Nonnull)aDecoder OBJC_DESIGNATED_INITIALIZER;
- (void)pressed:(UIButton * _Null_unspecified)sender;
- (void)viewWillLayoutSubviews;
- (SweetAlert * _Nonnull)showAlert:(NSString * _Nonnull)title SWIFT_WARN_UNUSED_RESULT;
- (nonnull instancetype)initWithNibName:(NSString * _Nullable)nibNameOrNil bundle:(NSBundle * _Nullable)nibBundleOrNil SWIFT_UNAVAILABLE;
@end


@interface UIColor (SWIFT_EXTENSION(demo))
@end

#pragma clang diagnostic pop
  • Can only use showAlert: API Can't meet the project requirements
  • Then I translated into Objective-C language version
  • If the infringement to you, please contact me, I will delete it
  • SJAlertView

Crashing always

Always crashes at line 243
let window: UIWindow = UIApplication.sharedApplication().keyWindow! with error
fatal error: unexpectedly found nil while unwrapping an Optional value

i am calling following code in my viewController in viewDidLoad() method
SweetAlert().showAlert("Good job!", subTitle: "You clicked the button!", style: AlertStyle.Success)

screen shot 2016-02-04 at 17 54 56

`

Tap outside the alert to dismiss it

Hello my friend, I have been struggling with this issue and I just can't make it work, I hope you can help me if this is posible or not, I noticed it does work in web and Android, but for some reason I cant find where to make it work in your code, and the function that allows me to do that or a similar one in Android, doesn't exist in this library. Best regards.

This is cool!

As cool as this is I really don't want to use it in the project I'm working on until there is an 'autoDismiss' option

More Cocoapod compatible

Hi,

This is a very nice Alert I'm using in my project, I would like to recommend to structure the project as CocoaPods compatible that should pass all the validations of the command:

pod lib lint SweetAlert.podspec

I've created a branch develop in my fork, if you are interested in a PR (#44).

Thanks,
J.

Button title length issue

I noticed that if you set the button titles too long, it causes the button width to extend and look ugly.

Help with using with Objective-C project

How do I use this in my Objective-C project. It lets me do the :

        SweetAlert *newAlert=[[SweetAlert alloc]init];
        [newAlert showAlert:@"Error"];

but none of the customizing like adding a subtitle or changing the type of alert.
Any help is appreciated. Thanks!

Changing size of the animateView

Hi,
Thanks for sharing the code.
The issue I face is that when we change the size of the animate view the bezirepath that draws the tick of success animate view draws bad.
It seems that the code for drawing this tick is harcoded based on size 70 and when I change the size to 50 it draws bad.

May you please help me how to fix this?

2 inquiries :)

Hi,

First off great work with this. super light weight and works great!! I had two inquiries to ask for

  1. Clear alert after x seconds without button press
    I was wondering if there is any way to clear the alert, x seconds after it pops up. sort of to notify that an action was completed and thats it. Without the users engagement or such.
  2. Custom alert view with activityIndicator
    Also if there is a way to add a loading indicator in the custom image?

Support ios9 Multitasking

UIScreen.mainScreen().bounds must be replaced by UIScreen.mainScreen().applicationFrame

will this library be updated in the future?

best regards
Alex

Custom image not cleaned

If you were to change SweetAlert() to your alert variable across the ViewController, you would notice that the custom image doesn't get cleaned properly.

Example. click the custom image button then check the other alerts.

Relocate above keyboard upon keyboard appearance

If you use SweetAlert on iOS 9 on iPad, the keyboard can appear at any time even if your app didn't initiate it. The keyboard will often cover up the SweetAlert. To resolve this, it should listen for the keyboard will show and will hide notifications and relocate appropriately.

xcode 8 ios 10

Gives that warnings !

ViewController.swift:32:22: Result of call to 'showAlert' is unused
ViewController.swift:38:22: Result of call to 'showAlert(_:subTitle:style:)' is unused

like this about 12 warnings

swift 4.0

/SweetAlert.swift:492:57: 'M_PI' is deprecated: Please use 'Double.pi' or '.pi' to get the value of correct type and avoid casting.

Swift3

Any chance on an update for Swift3?

Alert doesn't show in some cases.

I had to change this line:
let window = UIApplication.sharedApplication().keyWindow?.subviews.first as UIView
to this (notice the .last) to get it to work for me from a modally presented view controller within an app.
let window = UIApplication.sharedApplication().keyWindow?.subviews.last as UIView
It seems to work, but I'm not really sure what the correct change should be.

isOtherButton value is wrong

isOtherButton param value is true for first button and false for other button
Function cloaseAlert has line:
let isOtherButton = buttonIndex == 0 ? true: false
But otherButton index is 1 - condition is incorrect

How can I generate this instance?

I introduced this with cocoapods.

I want to generate this instance with "SweetAlert()".
However, this initializer is internal.
Isn't it impossible?

Make the class a singleton

Wouldn't it better to make the class a singleton so that there is only one instance.
You would then just call functions:

SweetAlert.sharedInstance.showAlert("Here's a message!")

Just need the:
static let sharedInstance = SweetAlert()

and make the init() private.

Very nice work, thanks!!

Better Installation Section

Hey, your library is really interesting.

The only problem I found was the README.md, which needs a better Installation Section
I created this iOS Open source Readme Template so you can take a look on how can improve your Installation Section
If you want, I can help you to organize the lib.

What are your thoughts? 😄

Better Installation Section

Hey, your library is really interesting.

The only problem I found was the README.md, which needs a better Installation Section
I created this iOS Open source Readme Template so you can take a look on how can improve your Installation Section
If you want, I can help you to organize the lib.

What are your thoughts? 😄

Hide Button and automatic dismiss

I am using this and i want to hide OK button from success alert. It should be dismiss by default after 3 seconds or user can set the time.
I didn't get the frame of Button. Please guide me.

autorezisingMask & buttonType

i am using xcode 6.4
i was not able to compile the project because there was a problem with autoresizing and the button type. i changed the code and it works..

self.view.autoresizingMask = UIViewAutoresizing.FlexibleHeight
let button = UIButton.buttonWithType(UIButtonType.Custom) as! UIButton

thanks for this awesome tiny library

Xcode 6.3 version doesn't compile

Hi
I am trying to run the Xcode version 6.3 for the code but it doesn't compile. IT raises lot of issues related to init and type methods.
I could resolve the type methods error but not init one. Can you help ?
-Randeep

Dismiss alert

How to dismiss the alert when user tapped the out side of the alert view ?

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.