0

Possible Duplicate:
Can I show an UISegmentedControl object in vertical?

How to make a UIsegmentController vertical ,I tried using,

segmentedControl.transform = CGAffineTransformMakeRotation(M_PI / 2.0);

but its make the segment control fonts to vertical.Can any one help me to code for vertical segmentcontrolbar?

4

2 回答 2

0

用这个,

NSArray *arr = [segmentedControl subviews];
    for (int i = 0; i < [arr count]; i++) {
    UIView *v = (UIView*) [arr objectAtIndex:i];
    NSArray *subarr = [v subviews];
        for (int j = 0; j < [subarr count]; j++) {
            if ([[subarr objectAtIndex:j] isKindOfClass:[UILabel class]]) {
                UILabel *l = (UILabel*) [subarr objectAtIndex:j];
                l.transform = CGAffineTransformMakeRotation(- M_PI / 2.0);
            }
        }
    }

请参阅我可以垂直显示 UISegmentedControl 对象吗?

于 2012-10-08T06:58:19.930 回答
-1

尝试以下代码并进行一些更改...

首先在 .m 文件顶部定义弧度,如下所示。

#define degreesToRadians(x) (M_PI * x / 180.0)

viewDidLoad:or之后viewWillAppear:,尝试下面的代码......

yoursegControl.transform = 
                CGAffineTransformRotate(segControl.transform, degreesToRadians(90));

*尝试Dropdawn List,这是给你的要求的输出*

嘿,如果您使用此 seg 控件的 Dropdawn 列表,那么它对您的要求也很有用,请参阅...

http://code.google.com/p/dropdowndemo/downloads/list

:)

于 2012-10-08T06:52:04.360 回答