iphone - UIPickerView 高度不可更改

标签 iphone ios frame uipickerview

<分区>

我正在尝试更改 PickerView 的高度

self.pickerView = [[UIPickerView alloc] init];
self.pickerView.frame = CGRectMake(0, 0, frame.size.width, frame.size.height);

Xcode 日志显示以下消息:

-[UIPickerView setFrame:]: invalid height value 274.0 pinned to 216.0 

如何改变它的高度?

最佳答案

这里只有three valid heights对于 UIPickerView (162.0, 180.0 and 216.0) .

您可以使用 CGAffineTransformMakeTranslationCGAffineTransformMakeScale功能以适本地适合您的选择器以方便您。

示例:

CGAffineTransform t0 = CGAffineTransformMakeTranslation (0, pickerview.bounds.size.height/2);
CGAffineTransform s0 = CGAffineTransformMakeScale       (1.0, 0.5);
CGAffineTransform t1 = CGAffineTransformMakeTranslation (0, -pickerview.bounds.size.height/2);
pickerview.transform = CGAffineTransformConcat          (t0, CGAffineTransformConcat(s0, t1));

以上代码change heightpicker view to halfre-position准确地说 (Left-x1, Top-y1)位置。

引用更多here .

关于iphone - UIPickerView 高度不可更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12473566/

相关文章:

swift - 当我从另一个 View 返回后, View 框架改变了它的位置[swift]

ios - iPhone6,6+ 未显示在 App Store 的兼容性部分

iphone - iOS 获取用户 iTunes 邮寄地址?在应用程序中购买真实产品以发货?

iphone - iPhone 上的键盘和起床状态

javascript - 从 iOS 到 WebSockets 的二进制数据

iphone - 使用 [NSThread sleepForTimeInterval :2. 0] 时可以停止或取消循环功能吗?在 IOS 中

ios - 在 iOS 上从版本 1.0 顺利过渡到 2.0 的注意事项

ios - UITableView “swipe to delete” 按钮框架问题

vb.net - vb.net 中的 Google Chrome 浏览器内嵌框架

iphone - -[__NSArrayM objectAtIndex :]: index 4294967295 beyond bounds for empty array with arc4random