你如何缩小iPhone上的UIPickerView? [英] How do you shrink a UIPickerView on the iPhone?

查看:103
本文介绍了你如何缩小iPhone上的UIPickerView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的iPhone应用程序中减少 UIPickerView 的高度,以便它只显示一行和一列。拾取器视图的高度应该等于行的高度。

I would like to reduce the height of a UIPickerView in my iPhone app, so that it shows only one row and one column. The height of the picker view should be equal to the height of a row.

我正在使用Interface Builder来构造 UIPickerView ,但我找不到一个简单的方法来重新调整此控件的大小。

I'm using Interface Builder to construct the UIPickerView, but I can't find an easy way to re-size this control.

如何缩小 UIPickerView

推荐答案

实际上,您可以通过将仿射变换应用于封闭视图来略微收缩整个UIPickerView。例如:

Actually, you can slightly shrink the whole UIPickerView by applying an affine transform to an enclosing view. For example:

CGSize pickerSize = [pickerView sizeThatFits:CGSizeZero];

pickerTransformView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, pickerSize.width, pickerSize.height)];
pickerTransformView.transform = CGAffineTransformMakeScale(0.75f, 0.75f);

[pickerTransformView addSubview:pickerView];
[self.view addSubview:pickerTransformView];
[pickerTransformView release];

将选择器缩放到原始大小的75%,方法是将其放置在包含视图中并应用缩放转换为该视图。将变换直接应用于UIPickerView会导致不合需要的绘图工件。

will scale a picker to 75% of its original size by placing it within a containing view and applying a scaling transform to that view. Applying a transform directly to the UIPickerView leads to undesirable drawing artifacts.

但是,通过创建自定义控件可以最好地满足您所需的调整大小。

However, the kind of resizing you're looking for would be best served by creating a custom control.

这篇关于你如何缩小iPhone上的UIPickerView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆