2017-08-29 68 views
1

通过遵循SDK示例中的示例,我已将搜索栏添加到我的应用程序。 like this边界在nativeScript中搜索栏的半径

我想给它圆角和灰色边框。对于我试图做这样的事情:

@ViewChild('searchBarSchool') ngSearchBar: ElementRef; 
    ngAfterViewInit() { 
     this.nsSearchBar = this.ngSearchBar.nativeElement; 
     this.nsSearchBar.backgroundColor = new Color("pink"); 
     this.nsSearchBar.borderRadius = "2"; 
     this.nsSearchBar.borderBottomWidth = 10; 
     this.nsSearchBar.borderColor = new Color("gray"); 

    } 

,而在HTML,

<SearchBar #searchBarSchool hint="Search for school"(textChange)="onTextChange($event)" 
    (loaded)="onSearchBarLoaded($event)"></SearchBar> 

我可以看到背景颜色“粉红”承担UI效果,但borderRadius不起作用。 我推荐了SearchBar类borderRadius的确是其中的一个属性。

裁判:https://docs.nativescript.org/api-reference/classes/_ui_search_bar_.searchbar.html

有人可以帮助我,我需要一个圆角边框为我的搜索框。

+0

岂不'.nativeElement'财产给你基本的Android/iOS设备查看实例?在这种情况下,您尝试设置的属性都不是有效的。 – pkanev

回答

0

此时NativeScript不支持部分边框半径。 这意味着你可以设置边框宽度代替borderBottomWidth,然后你就可以设置borderRadius(但各个角落)。还讨论here

另一种可能性是讨论here