//自定义一个TextView

class Own_TextView: UITextView {

    override func caretRect(for position: UITextPosition) -> CGRect {

        return CGRect.zero

    }

    override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {

        if action == #selector(copy(_:)) || action == #selector(selectAll(_:)) {

            return false

        }

        if action == #selector(paste(_:)){

            return false

        }

        return super.canPerformAction(action, withSender: sender)

    }

}

//禁止复制粘贴

  override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {

       return false

 }

let textView = Own_TextView.init(frame: CGRect(x:5, y: NavigationBarHeight + 20, width: ScreenWidth – 10, height: screenHeight – NavigationBarHeight-398-20))

版权声明:本文为sicaiyitang原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/sicaiyitang/p/8692434.html