Vertical SegmentController

时间:2012-10-08 06:48:13

标签: iphone ios uisegmentedcontrol uifont

  

可能重复:
  Can I show an UISegmentedControl object in vertical?

如何使UIsegmentController垂直,我尝试使用,

segmentedControl.transform = CGAffineTransformMakeRotation(M_PI / 2.0);

但是它使段控制字体变为垂直。任何人都可以帮我编写垂直段控制栏吗?

2 个答案:

答案 0 :(得分: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);
            }
        }
    }

请参阅Can I show an UISegmentedControl object in vertical?

答案 1 :(得分:-1)

尝试使用以下代码进行更改...

首先在.m文件的顶部定义Radians,如下所示..

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

viewDidLoad:viewWillAppear:之后,请尝试以下代码...

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

* 尝试Dropdawn List,这就像你的需求*

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

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

:)