【问题标题】:iOS 7 - UIPickerView curved componentsiOS 7 - UIPickerView 弯曲组件
【发布时间】:2014-06-14 10:02:57
【问题描述】:

我只想知道如何在 iOS 7 中禁用 UIPickerView 组件的这种“弯曲效果”?

这是我使用具有 3 个组件的 UIPickerView 得到的:

这就是我想要的:

在这个屏幕中,我使用了 3 个 UIPickerViews,只有 1 个组件来模拟它

TL;DR:

我希望未选择的行居中而不是弯曲,如您在屏幕 #2 中看到的那样,但仍仅使用一个 UIPickerView。

有可能吗?如果是,请告诉我怎么做,谢谢!

【问题讨论】:

    标签: ios ios7 uipickerview


    【解决方案1】:

    我认为您必须创建自己的自定义控件:(

    根据 Apple 的 UIKit UI 目录:

    https://developer.apple.com/library/ios/documentation/userexperience/conceptual/UIKitUICatalog/UIPickerView.html

    选择器视图的外观(程序化)

    您不能自定义选择器视图的外观。

    据我所知,iOS7 下你甚至无法更改 UIPickerView 的背景颜色!

    【讨论】:

      【解决方案2】:

      您可以通过以下代码居中并选择一行:

      func pickerView(_ pickerView: UIPickerView, widthForComponent component: Int) -> CGFloat {
          return pickerView.frame.width / noOfComponent - (pickerView.frame.width / noOfComponent * noOfComponent)
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-11-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-10-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多