看起来像图像中的那个

看起来像图像中的那个

我需要制作一个ios - 如何使UIPickerView看起来像图像中的那个?-LMLPHP使其看起来像图像中的那个,它具有5个不同的部分,每个部分有2行。

最佳答案

 func configureDatePicker(){
        let datePicker = UIPickerView.init()
//        datePicker.datePickerMode = .Date
        datePicker.delegate = self
        datePicker.dataSource = self
        txtDOB.inputView = datePicker

        noteToolbar =  UIToolbar.init(frame: CGRectMake(0, 0, self.view.frame.size.width, 44))
        let btnDone = UIBarButtonItem.init(title: "Done", style: .Done, target: self, action: #selector(AboutYouViewController.datePicked))
        let btnCancel = UIBarButtonItem.init(title: "Cancel", style: .Done, target: self, action: #selector(AboutYouViewController.dismissKeyboard))
        let flexibleButton = UIBarButtonItem.init(barButtonSystemItem: .FlexibleSpace, target: self, action: nil)

        noteToolbar.items = [btnDone, flexibleButton, btnCancel]
        txtDOB.inputAccessoryView = noteToolbar
    }

func numberOfComponentsInPickerView( pickerView: UIPickerView) -> Int

    {
        return 1
    }

    func pickerView(pickerView: UIPickerView,
                      numberOfRowsInComponent component: Int) -> Int
    {
        return 3
    }
    func pickerView(_pickerView: UIPickerView,
                      titleForRow row: Int,
                                  forComponent component: Int) -> String?
    {
        return "Test"
    }


您可以根据需要进行修改,并可以使用pickerview的dalagate和数据源方法。它与UITableView委托和数据源一样易于使用

关于ios - 如何使UIPickerView看起来像图像中的那个?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/38694964/

10-09 16:30