如何在iOS中通过键盘显示UIView

前端之家收集整理的这篇文章主要介绍了如何在iOS中通过键盘显示UIView前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
用户点击inputAccessoryView中的“附加”按钮时,我想在键盘上创建一个简单的视图.
像这样的东西:

有一个简单的方法吗?或者我应该创建我的自定义键盘

解决方法

您可以将新的子视图添加到应用程序窗口.
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);
}
原文链接:https://www.f2er.com/iOS/332790.html

猜你在找的iOS相关文章