ios - 更改 UIPickerView 中文本的高度?

标签 ios swift uipickerview

如何更改 UIPickerView 中文本的高度?是否可以?我想降低默认高度。

最佳答案

SWIFT 2.2

在pickerView的委托(delegate)中实现pickerView(pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusingView view: UIView?) 方法。

func pickerView(pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusingView view: UIView?) -> UIView {
let label: UILabel = UILabel(frame: CGRectMake(0, 0, scalePicker!.frame.size.width / 2, scalePicker!.frame.size.height / 7))
        label.textColor = UIColor.whiteColor()
        label.font = UIFont(name: "Gotham-Medium", size: 20)
        switch component {
        case 0:
            label.text = height_array[row] as? String
            label.textAlignment = .Center
        case 1:
            label.text = unit_Arr[row] as? String
            label.textAlignment = .Left
        default:
            break
        }

        return label
}

关于ios - 更改 UIPickerView 中文本的高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44276983/

相关文章:

ios - pickerview 随机崩溃 didSelect : __cfrunloop_is_calling_out_to_a_source1_perform1_function

ios - Xcode 6.4 iOS 图表 API 错误

ios - TabBar 图像的大小应该是多少?

ios - 使 uipickerview 在触摸单元格时出现在单元格之间

ios - 使用 XLPagerTabStrip 在 child 之间传递数据

swift - 将选择器添加到 UIStepper 的 addTarget 函数时出错 - Swift 3

ios - iOS 版 Swift : change array order and populate Picker

iOS AVAudioPlayer 再次播放声音

ios - 使用 xcodebuild -exportArchive(Xcode8.3,自动签名)时如何获取分发应用程序?

ios - 如何正确设置分页 UICollectionView 大小变化的动画