iphone - 旋转 UIPickerView,可能吗?

标签 iphone cocoa-touch uikit uipickerview landscape

有没有办法旋转 UIPickerView?

最佳答案

//放置在 View 中的示例代码确实加载了

[super viewDidLoad];
myPicker.delegate = self;
myPicker.dataSource = self;
myPicker.showsSelectionIndicator =YES;
myPicker.backgroundColor = [UIColor blackColor];

CGAffineTransform rotate = CGAffineTransformMakeRotation(3.14/2);

//original settings
//rotate = CGAffineTransformScale(rotate, 0.1, 0.8);

rotate = CGAffineTransformScale(rotate, 0.2, 1.65);
[self.myPicker setTransform:rotate];    

NSMutableArray *array = [[NSMutableArray alloc] initWithObjects:@"155", @"165", @"175", 
                  @"185", @"195", @"205", @"215", nil];
self.pickerData = array; 
[array release];

NSInteger TOTALITEM = [pickerData count];

UILabel *theview[TOTALITEM-1]; // + 1 for the nil
for (int i=1;i<=TOTALITEM-1;i++) {  
 theview[i] = [[UILabel alloc] init];
 theview[i].text = [NSString stringWithFormat:@"%d",i];
 theview[i].textColor = [UIColor blackColor];
 theview[i].frame = CGRectMake(0,0, 25, 25);
 theview[i].backgroundColor = [UIColor clearColor];
 theview[i].textAlignment = UITextAlignmentCenter;
 theview[i].shadowColor = [UIColor whiteColor];
 theview[i].shadowOffset = CGSizeMake(-1,-1);
 theview[i].adjustsFontSizeToFitWidth = NO;

 UIFont *myFont = [UIFont fontWithName:@"Helvetica" size:30];
[theview[i] setFont:myFont];
}


CGAffineTransform rotateItem = CGAffineTransformMakeRotation(-3.14/2);
rotateItem = CGAffineTransformScale(rotateItem, .5, 5);


for (int j=1;j<=TOTALITEM-1;j++) { 
    theview[j].transform = rotateItem;

 }

pickerData = [[NSMutableArray alloc] init];


for (int j=1;j<=TOTALITEM-1;j++) { 
[pickerData addObject:theview[j]];
}

关于iphone - 旋转 UIPickerView,可能吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2162024/

相关文章:

ios - UIButton Action 选择器

ios - 从文件路径获取数据时崩溃

iphone - 用户触摸 UIButton 次数过多 iPhone

php - 在 App 中推送通知

objective-c - 子类化NSStream

ios - UITextView 内容插图

objective-c - 在 UISearchDisplayController 中没有结果时添加新项目

iphone - iOS书中奇怪的变量分配

iphone - 在我的应用程序中复制 iPhone 库的音乐文件

ios - 在iOS上暂停后恢复Spotify