如何在 iOS 中通过键盘显示 UIView [英] How to display UIView over keyboard in iOS

查看:18
本文介绍了如何在 iOS 中通过键盘显示 UIView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在键盘上创建一个简单的视图,当用户点击 inputAccessoryView 中的附加"按钮时.像这样:

I want to create a simple view over keyboard, when users tap "Attach" button in inputAccessoryView. Something like this:

有没有简单的方法来做到这一点?或者我应该创建我的自定义键盘?

Is there an easy way to do it? Or i should create my custom keyboard?

推荐答案

您可以将该新子视图添加到您的应用程序窗口.

You can add that new subview to your application window.

func attach(sender : UIButton)
{
    // Calculate and replace the frame according to your keyboard frame
    var customView = UIView(frame: CGRect(x: 0, y: self.view.frame.size.height-300, width: self.view.frame.size.width, height: 300))
    customView.backgroundColor = UIColor.redColor()
    customView.layer.zPosition = CGFloat(MAXFLOAT)
    var windowCount = UIApplication.sharedApplication().windows.count
    UIApplication.sharedApplication().windows[windowCount-1].addSubview(customView);
}

这篇关于如何在 iOS 中通过键盘显示 UIView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆