swift - 代碼建立 pickerView 顯示或隱藏橫線

來源:互聯網
上載者:User

標籤:file   als   ima   UNC   sele   self   fun   建立   selection   

 1 import UIKit 2  3 class VC1: UIViewController { 4      5     fileprivate lazy var pickerV : UIPickerView = { 6         let v = UIPickerView(frame: CGRect(x: 100, y: 100, width: 200, height: 400)) 7         v.delegate = self 8         v.dataSource = self 9         v.backgroundColor = .orange10 11         return v12     }()13 14     override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {15      view.addSubview(pickerV)16         pickerV.showsSelectionIndicator = false17         18     }19 }20 21 extension UIViewController:UIPickerViewDelegate, UIPickerViewDataSource{22     public func numberOfComponents(in pickerView: UIPickerView) -> Int {23         return 124     }25     26     public func pickerView(_ pickerView: UIPickerView, rowHeightForComponent component: Int) -> CGFloat {27         return 20028     }29     public func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {30         return 1031     }32     33     public func pickerView(_ pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusing view: UIView?) -> UIView {34         pickerView.subviews[1].backgroundColor = UIColor.blue35         pickerView.subviews[1].isHidden = false36         pickerView.subviews[2].backgroundColor = UIColor.purple37         pickerView.subviews[2].isHidden = false38         39         40         /// 倆根線中間的VIEW41         let v = UIView()42         v.frame = CGRect(x: 0, y: 0, width: 50, height:100)43         v.backgroundColor = UIColor.green44         return v45     }46 }



 

swift - 代碼建立 pickerView 顯示或隱藏橫線

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.