@@ -3,9 +3,12 @@ import {
33 SearchBarBase , Color , colorProperty , backgroundColorProperty , backgroundInternalProperty , fontInternalProperty ,
44 textProperty , hintProperty , textFieldHintColorProperty , textFieldBackgroundColorProperty
55} from "./search-bar-common" ;
6+ import { ios as iosUtils } from "../../utils/utils" ;
67
78export * from "./search-bar-common" ;
89
10+ const majorVersion = iosUtils . MajorVersion ;
11+
912class UISearchBarDelegateImpl extends NSObject implements UISearchBarDelegate {
1013 public static ObjCProtocols = [ UISearchBarDelegate ] ;
1114
@@ -52,6 +55,18 @@ class UISearchBarDelegateImpl extends NSObject implements UISearchBarDelegate {
5255 }
5356}
5457
58+ class UISearchBarImpl extends UISearchBar {
59+ sizeThatFits ( size : CGSize ) : CGSize {
60+ // iOS11 SDK does not support passing sizeThatFits(...) non-finite width value;
61+ // iOS layout system will take care to size the element properly when passed 0
62+ if ( majorVersion >= 11 && size . width === Number . POSITIVE_INFINITY ) {
63+ size . width = 0 ;
64+ }
65+
66+ return super . sizeThatFits ( size ) ;
67+ }
68+ }
69+
5570export class SearchBar extends SearchBarBase {
5671 private _ios : UISearchBar ;
5772 private _delegate ;
@@ -61,7 +76,7 @@ export class SearchBar extends SearchBarBase {
6176 constructor ( ) {
6277 super ( ) ;
6378
64- this . nativeViewProtected = this . _ios = UISearchBar . new ( ) ;
79+ this . nativeViewProtected = this . _ios = UISearchBarImpl . new ( ) ;
6580 this . _delegate = UISearchBarDelegateImpl . initWithOwner ( new WeakRef ( this ) ) ;
6681 }
6782
0 commit comments