12

I'm having trouble removing this tick when text is selected, I've tried this:

class CustomUITextField: UITextField {
   open override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
      return false
   }
}

which removes stuff like copy, paste etc, but doesn't seem to remove this new iOS 16 feature. Thankful for any help :)

enter image description here

Pontus
  • 44
  • 13

2 Answers2

11

you can try:

    - (void)buildMenuWithBuilder:(id<UIMenuBuilder>)builder API_AVAILABLE(ios(13.0))  {
        if (@available(iOS 16.0, *)) {
            [builder removeMenuForIdentifier:UIMenuLookup];
        }
        [super buildMenuWithBuilder:builder];
    }
user19783633
  • 126
  • 1
  • 2
5

Add the following code to your custom subclass:

@available(iOS 13.0, *)
override func buildMenu(with builder: UIMenuBuilder) {
    builder.remove(menu: .lookup)

    super.buildMenu(with: builder)
}
Kqtr
  • 5,824
  • 3
  • 25
  • 32
Hassan Taleb
  • 2,350
  • 2
  • 19
  • 24