简体   繁体   English

如何快速显示自定义键盘应用程序中的小弹出窗口?

[英]How to show a small pop up in custom keyboard app in swift?

My app is a keyboard extension app, i need to show a nice little pop up which says copied once i copy an image to pasteboard. 我的应用程序是键盘扩展程序应用程序,我需要显示一个漂亮的小弹出窗口,说我将图像复制到粘贴板后即被复制。

let data = UIImagePNGRepresentation(drawView.getImage())
UIPasteboard.generalPasteboard().setData(data!, forPasteboardType: "public.png")

I need to display a nice pop up which says "copied" after this code. 我需要在此代码后显示一个漂亮的弹出窗口,其中显示“已复制”。

I found this API very useful for me. 我发现此API对我非常有用。 https://github.com/devxoul/JLToast https://github.com/devxoul/JLToast

See my updated code here. 在这里查看我的更新代码。

let data = UIImagePNGRepresentation(drawView.getImage())
    UIPasteboard.generalPasteboard().setData(data!, forPasteboardType: "public.png")


    toastView = JLToastView()
    toastView.textLabel.text = "Copied!"
    self.view.addSubview(toastView)
    UIView.animateWithDuration(0.5, animations: {
        self.toastView.alpha = 0.0
    })

if you want to temporary pop up for some here is good one library which is written in Objective C you can use in swift also 如果您想临时弹出某些内容,这是一个很好的库,它是用Objective C编写的,也可以快速使用

https://github.com/alexleutgoeb/ALToastView https://github.com/alexleutgoeb/ALToastView

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM