//自定义一个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))
请发表评论