如何更改搜索栏的高度?迅速

时间:2015-07-16 06:10:00

标签: ios swift uisearchbar

我有这个:

http://postimg.org/image/oepn8hhzd/

我需要这个:

http://postimg.org/image/4bacislw5/

我的搜索栏代码

function validate()
 {
var cal1 = document.getElementById('<%=txtEndDate.ClientId%>').value;
var cal2 = document.getElementById('<%=txtStartDate.ClientId%>').value;
var button=document.getElementById('<%=button1.ClientId %>')

        if (cal1 == '') {
            alert("End Date can not be left blank ");
            return false;
        }
        if (cal2 == '') {
            alert("Start Date can not be left blank ");
            return false;
        }

        if (cal1 != '' || cal2 != '')
         {
            var dt1 = Date.parse(cal1);
            var dt2 = Date.parse(cal2);
            if (dt1 <= dt2) {
                alert("End Date must occur after the Start date ");
                return false;
            }
        }
     //if the all the validation are correct it comes to this
        if (button.value == "Enable")
            button.value = "Disable";
        else
            button.value = "Enable";

        return false;
    }

有什么想法吗? (对不起链接,我无法插入图片)

1 个答案:

答案 0 :(得分:3)

您可以使用其他视图作为导航栏标题并在其中放置搜索栏。

let searchController = UISearchController(searchResultsController: nil)
searchController.hidesNavigationBarDuringPresentation = false
searchController.dimsBackgroundDuringPresentation = false
searchController.searchBar.delegate = self

let frame = CGRect(x: 0, y: 0, width: 100, height: 44)
let titleView = UIView(frame: frame)
searchController.searchBar.backgroundImage = UIImage()
searchController.searchBar.frame = frame
titleView.addSubview(searchController.searchBar)
navigationItem.titleView = titleView

希望这会有所帮助。