Swift의 사용자 정의 SearchInput

1178 단어 swift
직접 부호
<span style="font-family:Comic Sans MS;font-size:24px;">    /**
         
    */
    func setupSearchBar() {
        let searchInput = UITextField();
        //       ,            
        searchInput.background = UIImage.resizableImageWithName("searchbar_background");
        //   
        let margin: CGFloat = 5;
        //          
        let iconView = UIImageView(image: UIImage(named: "searchbar_textfield_search_icon"));
        //        
        iconView.frame.size = CGSizeMake(iconView.frame.size.width + margin * 2, iconView.frame.size.height);
        //          
        iconView.contentMode = UIViewContentMode.Center;
        //          
        searchInput.leftView = iconView;
        //          
        searchInput.leftViewMode = UITextFieldViewMode.Always;
        //       
        searchInput.placeholder = "     :   ";
        //       
        searchInput.font = UIFont.systemFontOfSize(12);
        //           
        searchInput.bounds = CGRectMake(0, 0, self.view.frame.width * 0.99, 30);
        self.navigationItem.titleView = searchInput;
    }
</span>

좋은 웹페이지 즐겨찾기