Introduction to Swift Development: Search box (Uisearchbar)

Source: Internet
Author: User

reprint Please declare source: http://blog.csdn.net/jinnchang/article/details/44827923
------------------------------------------------------------------------------------------
code Example
viewcontroller.swift//uisearchbarsample////Created by Jinnchang on 15/4/1.//Copyright (c) 2015 Jinn Chang. All rights Reserved.//import Uikitclass Viewcontroller:uiviewcontroller,uisearchbardelegate {var Searchbar:uisea    rchbar! Override Func Viewdidload () {super.viewdidload ()//Do any additional setup after loading the view, typical                Ly from a nib.        Searchbar = Uisearchbar (Frame:cgrectmake (0, Self.view.frame.size.width, +)) Searchbar.placeholder = "Search" Searchbar.prompt = "prompt" Searchbar.text = "text" Searchbar.barstyle = Uibarstyle.default se Archbar.searchbarstyle = Uisearchbarstyle.default Searchbar.bartintcolor = Uicolor.orangecolor () searchBar.t Intcolor = Uicolor.redcolor () Searchbar.translucent = True Searchbar.showsbookmarkbutton = True Searc Hbar.showscancelbutton = True Searchbar.showssearchresultsbutton = False searchbar.showsscopeBar = False searchbar.delegate = self Self.view.addSubview (searchbar)} override func Didrecei    Vememorywarning () {super.didreceivememorywarning ()//Dispose of any resources the can be recreated. }//Input box Contents change Trigger event func Searchbar (Searchbar:uisearchbar, Textdidchange searchtext:string) {println ("filter: \ (SearchText)}//Bookmark button Trigger event func searchbarbookmarkbuttonclicked (Searchbar:uisearchbar) {println ("search        History ")}/Cancel Button trigger event func searchbarcancelbuttonclicked (Searchbar:uisearchbar) {println (" Cancel Search ")} Search Trigger event func searchbarsearchbuttonclicked (Searchbar:uisearchbar) {println ("Start Search")}}
------------------------------------------------------------------------------------------
results show
------------------------------------------------------------------------------------------
ConclusionProject on GitHub address: uisearchbarsample

Article last updated: April 2, 2015 09:35:35. For more information, refer to:

Uisearchbar Class Reference

UIKit User Interface Catalog:search Bars

Introduction to Swift Development: Search box (Uisearchbar)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.