
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 显示或隐藏横线全部内容,希望文章能够帮你解决swift - 代码创建 pickerView 显示或隐藏横线所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)