Code Monkey home page Code Monkey logo

toast-swift's Introduction

Toast-Swift

Toast view using swift.

New Screenshot 1 New Screenshot 2 New Screenshot 3

New Toast-Swift has been updated!


New Toast-Swift can compile with Swift 3.0.
And u can set the theme color of the toast view.

Install


download this repo and import "UIView+HRToast".

Usage


  1. Set theme color (defalut is UIColor.blackColor())

    view.hr_setToastThemeColor(color: #ThemeColor)
    
  2. Single toast view

    First Screenshot

    view.makeToast(message: msg)
    
  3. Toast with title

    Second Screenshot

    view.makeToast(message: msg, duration: duration, position: pos, title: subject)
    
  4. Toast with image, title...

    Third Screenshot

    view.makeToast(message: msg, duration: duration, position: pos, title: subject, image: image)
    
  5. Show and hide activity

    Fourth Screenshot

    view.makeToastActivity()
    view.hideToastActivity()
    
  6. Show activity with message

    Fifth Screenshot

    view.makeToastActivityWithMessage(message: msg)
    

LICENSE


The MIT License (MIT)

Copyright (c) 2017 Hanran Liu

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.

toast-swift's People

Contributors

alambel avatar amcinerneynewf avatar antuaaan avatar armstrongnate avatar athiwatc avatar cliff2103 avatar digitalcatnip avatar drkcloudstrife avatar dubiao avatar fbente avatar ilkerdagli avatar kukaly avatar moliholy avatar rannie avatar tsuncp 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

toast-swift's Issues

How to destroy last toast before showing a new one?

I'd like to show a toast where its possible to have a set of stacked toasts on top of each other. How can I destroy or hide the last one before showing a new one? Having stacked toasts look ugly with the shadows etc.

carthage and Toast-Swift

i run install Toast-Swift with carthage,

Cartfile:

github "Rannie/Toast-Swift" == 0.1.3

But i have the error:

*** Cloning Toast-Swift
*** Checking out Toast-Swift at "0.1.3"
*** xcodebuild output can be found in /var/folders/b8/2fbbzdj14dzdfzgxyk7qlqqh0000gn/T/carthage-xcodebuild.U8awn3.log
Project "ToastDemo.xcodeproj" has no shared schemes

If you believe this to be an error, please file an issue with the maintainers at https://github.com/Rannie/Toast-Swift/issues/new

Will you cut another version of the POD?

Myself and some others had sent in some PRs that were accepted but there hasn't been another publish of the cocoapod. Can you bump the version and republish so that we can utilize it? Thanks!

Toast Hidden with keyboard

if the keyboard is visible, the toast is behind it and it isnt seen, is there a way to fix this or move it with the keyboard on show?

Thanks!

issues in tableView

thx for this
but in tableview, and if scroll tableview down , the position of toast view will be wrong

Crash

func handleToastTapped(recognizer: UITapGestureRecognizer) {
print("object1")
var timer = objc_getAssociatedObject(self, &HRToastTimer) as! NSTimer
timer.invalidate()
print("object2")
if(recognizer.view != nil){
self.hideToast(toast: recognizer.view!)
}

}

sometimes when you repeatedly click toast message view I can see "object1" in output but not "object2" and app is crashed

Ambiguos reference makeToast

Ambiguous reference to member 'makeToast(message:)'
this all candidates:

func makeToast(message msg: String) {
makeToast(message: msg, duration: HRToastDefaultDuration, position: HRToastPositionDefault as AnyObject)
}

func makeToast(message msg: String, duration: Double, position: AnyObject) {
    let toast = self.viewForMessage(msg, title: nil, image: nil)
    showToast(toast: toast!, duration: duration, position: position)
}

func makeToast(message msg: String, duration: Double, position: AnyObject, title: String) {
    let toast = self.viewForMessage(msg, title: title, image: nil)
    showToast(toast: toast!, duration: duration, position: position)
}

func makeToast(message msg: String, duration: Double, position: AnyObject, image: UIImage) {
    let toast = self.viewForMessage(msg, title: nil, image: image)
    showToast(toast: toast!, duration: duration, position: position)
}

func makeToast(message msg: String, duration: Double, position: AnyObject, title: String, image: UIImage) {
    let toast = self.viewForMessage(msg, title: title, image: image)
    showToast(toast: toast!, duration: duration, position: position)
}

Crash when clicking on toast quickly

I found a crash when you click on the toast quickly after it appears. To fix it I changed this

    let timer = objc_getAssociatedObject(self, &HRToastTimer) as! NSTimer {

to this

    if let timer = objc_getAssociatedObject(self, &HRToastTimer) as? NSTimer {

How to call from Table Cell button action?

I have a UITableViewController and inside each cell is a button.

I am using an addTarget to attach a handler for the buttons, and inside the handler, I am using self.view.makeToast(), but the toast doesn't display.

I assume it is due to using self.view inside the handler.

Any ideas on how to get this to work?

Thanks!

pos values

Perhaps, to specify a position for the toast, an enum would be better to specify: top, center, bottom

enum Position {top, center, bottom}

Problem when try show concatenate toast activity

Hi, I want to concatenate two messages as toast activity, but it doesn't work. Here is mi code:

func testToast(){
        self.view.makeToastActivity(message: "1")
        DispatchQueue.global().async {
            sleep(1)
            DispatchQueue.main.async {
                self.view.hideToastActivity()
                self.view.setNeedsLayout()
                self.view.makeToastActivity(message: "2")
            }
            sleep(1)
            DispatchQueue.main.async {
                self.view.hideToastActivity()
            }
        }
    }

Only the first toast activity is showed and (after 1 second) it is hidden, but the second toast activity never show. Why?, Someone can help me to do what I want????

Thanks in advance!

Toast message does not resize based on content

I updated HRToast + UIView.swift from previous Swift 3 to latest Swift 4 support and I noticed that long toast messages no longer resize the toast message view.

Swift 3:
image

Swift 4:
image

I'm not too familiar with Swift and I'm still learning but I noticed that the issue comes from let desiredSize = toast.systemLayoutSizeFitting(UILayoutFittingCompressedSize). I tested this on iOS 10.1.

line 441 extension String

When I use xcode 7.3 building , there is a error for attribute declaring :
/HRToast+UIView.swift:440:26: Type of expression is ambiguous without more context
Can you help me ?

Using CocoaPod to install, UIView does not have a member named 'makeToast'

I integrated the Cocoapod and when trying call the makeToast method like so:

self.view.makeToast(message: "test", duration: GlobalVars.TOAST_DURATION, position: GlobalVars.TOAST_POSITION)

I receive a warning that says 'UIView' does not have a member named 'makeToast'. I did the import ToastSwift for that class as well.

Also, it does not recognize the constants, HRToastPosition.

How do I fix this?

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.