| | |
| | | } |
| | | |
| | | private func setUI(){ |
| | | var items = Array<String>() |
| | | items.append("省") |
| | | items.append("市") |
| | | items.append("区") |
| | | |
| | | let stackView = UIStackView() |
| | | stackView.axis = .horizontal |
| | | stackView.distribution = .fillEqually |
| | | stackView.spacing = 133 |
| | | view_content.addSubview(stackView) |
| | | stackView.snp.makeConstraints { make in |
| | | make.top.equalTo(label_title.snp.bottom).offset(27) |
| | | make.height.equalTo(25) |
| | | make.centerX.equalToSuperview() |
| | | } |
| | | |
| | | for (_,v) in items.enumerated(){ |
| | | let label = UILabel() |
| | | label.text = v |
| | | label.font = UIFont.systemFont(ofSize: 18, weight: .medium) |
| | | label.textColor = .black.withAlphaComponent(0.8) |
| | | label.textAlignment = .center |
| | | stackView.addArrangedSubview(label) |
| | | } |
| | | |
| | | view_content.addSubview(btn_complete) |
| | | btn_complete.snp.makeConstraints { make in |
| | | make.bottom.equalToSuperview().offset(-UIDevice.jq_safeEdges.bottom) |
| | | make.centerX.equalToSuperview() |
| | | make.width.equalTo(JQ_ScreenW * 0.1487) |
| | | make.width.equalTo(316) |
| | | make.height.equalTo(47) |
| | | } |
| | | |
| | |
| | | make.top.equalTo(label_title.snp.bottom).offset(50) |
| | | make.bottom.equalTo(btn_complete.snp.top) |
| | | make.centerX.equalToSuperview() |
| | | make.width.equalTo(500) |
| | | make.width.equalTo(350) |
| | | } |
| | | |
| | | btn_complete.addTarget(self, action: #selector(completeAction), for: .touchUpInside) |
| | |
| | | pickerView.clouse = clouse |
| | | sceneDelegate?.window?.addSubview(pickerView) |
| | | pickerView.setUI() |
| | | pickerView.label_title.text = title |
| | | |
| | | UIView.animate(withDuration: 0.35) { |
| | | pickerView.backgroundColor = UIColor.black.withAlphaComponent(0.7) |
| | |
| | | pickerView.layoutIfNeeded() |
| | | }completion: { _ in |
| | | Services.addressTree().subscribe(onNext: {data in |
| | | pickerView.items = data.data ?? [] |
| | | pickerView.picker.reloadAllComponents() |
| | | if let datas = data.data{ |
| | | pickerView.items = datas |
| | | pickerView.picker.reloadAllComponents() |
| | | } |
| | | }).disposed(by: pickerView.disposeBag) |
| | | } |
| | | } |
| | |
| | | extension CityAddressPickerView:UIPickerViewDelegate & UIPickerViewDataSource{ |
| | | func numberOfComponents(in pickerView: UIPickerView) -> Int { |
| | | if items.count > 0{ |
| | | return 3 |
| | | return 2 |
| | | } |
| | | return 0 |
| | | |
| | |
| | | resultLabel!.font = UIFont.systemFont(ofSize: 18, weight: .semibold) |
| | | resultLabel!.textColor = UIColor(hexStr: "#3C3C3C") |
| | | resultLabel!.textAlignment = .center |
| | | resultLabel!.adjustsFontSizeToFitWidth = true |
| | | } |
| | | |
| | | if component == 0{ |
| | |
| | | func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { |
| | | if component == 0{ |
| | | pickerView.reloadComponent(1) |
| | | pickerView.reloadComponent(2) |
| | | } |
| | | |
| | | if component == 1{ |
| | | pickerView.reloadComponent(2) |
| | | |
| | | } |
| | | } |
| | | } |