SearchTextField icon indicating copy to clipboard operation
SearchTextField copied to clipboard

inlineMode not working on iOS11

Open KohFujimura opened this issue 6 years ago • 1 comments

let mySearchTextField = SearchTextField(frame: CGRect(x:10, y: 100, width:200, height:40)) // Set the array of strings you want to suggest mySearchTextField.backgroundColor = UIColor.red mySearchTextField.inlineMode = true mySearchTextField.filterStrings(["Red", "Blue", "Yellow"]) self.view.addSubview(mySearchTextField)

"the above code" runs really well on iOS 10 but iOS 11 one more thing, the example still work on iOS 11 but when i take the textfield out of table, then put it into a new ViewController. it doesn't work anymore. really really dont understand this bug

KohFujimura avatar Apr 29 '18 17:04 KohFujimura

Hello, @KohFujimura!

fileprivate func buildPlaceholderLabel() {
        var newRect = self.placeholderRect(forBounds: self.bounds)
        var caretRect = self.caretRect(for: self.beginningOfDocument)
        let textRect = self.textRect(forBounds: self.bounds)

On iOS 11 func placeholderRect(forBounds bounds: CGRect) -> CGRect or newRect returned height is equal to zero if placeholder empty. I fixed that, appending space into placeholder. Hope it helps you :)

Ikloo avatar Jul 04 '18 19:07 Ikloo