How to display UIView over keyboard in iOS

前端 未结 7 912
醉话见心
醉话见心 2020-12-05 20:04

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? O

相关标签:
7条回答
  • 2020-12-05 20:44

    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);
    }
    
    0 讨论(0)
提交回复
热议问题