今天写了一个ActionSheet添加的UIPickerView的程序,搜索了很多的资料
- (void)configurePickersAndActionSheets {
CGRect pickerFrame;
if ((self.interfaceOrientation == UIInterfaceOrientationPortrait) ||
(self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)) {
pickerFrame = CGRectMake(0, 180, 0, 0);
} else {
pickerFrame = CGRectMake(0,180,480,200);
}
self.areaActionSheet = [[[UIActionSheet alloc] initWithTitle:@"Area" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Use",NULL] autorelease];
self.areaPicker = [[[UIPickerView alloc] initWithFrame:pickerFrame] autorelease];
self.areaPicker.delegate = self;
self.areaPicker.showsSelectionIndicator = YES;
[self.areaActionSheet addSubview:areaPicker];
}
上面的代码就是横屏和纵屏的大小设置
if ((self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft) ||
(self.interfaceOrientation == UIInterfaceOrientationLandscapeRight)) {
[actionSheet setBounds:CGRectMake(0, 0, 480, 480)];
} else {
[actionSheet setBounds:CGRectMake(0, 0, 320, 618)];
}
此处用来设置actionsheet的大小
具体的添加PickerView如下:
UIActionSheet *menu = [[UIActionSheet alloc] initWithTitle:[currentData objectAtIndex:0]
delegate:self
cancelButtonTitle:@"Done"
destructiveButtonTitle:@"Cancel"
otherButtonTitles:nil];
UIPickerView *pickerView = [[UIPickerView alloc]initWithFrame:CGRectMake(0,40,480,200)];
pickerView.delegate = self;
pickerView.showsSelectionIndicator = YES;
[menu addSubview:pickerView];
[menu showInView:self.view];
[menu setBounds:CGRectMake(0,0,480, 320)];
[pickerView release];
[menu release];
OK这个就完成了ActionSheet的操作,可能你还会有一个问题就是在UIPickerView如何设置显示下拉框的
字体大小,即改变显示数组中的字体大小:
需要重写实现如下方法
- (UIView *)pickerView:(UIPickerView *)pickerView
viewForRow:(NSInteger)row
forComponent:(NSInteger)component
reusingView:(UIView *)view{
UILabel *pickerLabel = (UILabel *)view;
if ((pickerLabel == nil) || ([pickerView class] != [UILabel class])) {
CGRect frame = CGRectMake(0, 0, 270, 32);
pickerLabel = [[UILabel alloc] initWithFrame:frame];
pickerLabel.textAlignment =UITextAlignmentLeft;
pickerLabel.backgroundColor = [UIColor clearColor];
pickerLabel.font = [UIFont boldSystemFontOfSize:18];
if (component == kStateComponent) {
pickerLabel.textAlignment = UITextAlignmentCenter;
pickerLabel.text = [self.states objectAtIndex:row];
}
else if(component == kZipComponent){
pickerLabel.textAlignment =UITextAlignmentLeft;
pickerLabel.text = [self.zips objectAtIndex:row];
}
pickerLabel.textColor = [UIColor blackColor];
return pickerLabel;
}
return 0;
}
这样就解决字体大小的问题了.
分享到:
相关推荐
DoActionSheet, UIActionSheet的替换 DoActionSheet替代 UIActionSheet: 基于块,可以定制主题,易于使用图像或者地图预览带有标题,带有破坏性按钮的,带有取消按钮和图像 如果按钮有许多按钮但按钮的位置是固定的...
SQActionSheetView *acitionSheet = [[SQActionSheetView alloc]initWithTitle:@"" buttons:@[@"保存图片",@"分享图片",@"取消"] buttonClick:^(SQActionSheetView *sheetView, NSInteger buttonIndex) { ...
ActionSheetPicker = UIPickerView + UIActionSheet
IOS应用源码——UIActionSheet 的美化效果.zip
IOS应用源码——UIActionSheet 的美化效果.rar
模仿IOS里面的UIActionSheet控件.rar,太多无法一一验证是否可用,程序如果跑不起来需要自调,部分代码功能进行参考学习。
BlockUI-iOS ,使用 block 做回调的 UIAlertView,UIActionSheet.UIControl ...
IBActionSheet ,IBActionSheet 是一个可完全可定制的 iOS 7 风格的 UIActionSheet 替...
FSMediaPicker ,FSMediaPicker 集成的摄像机和本地相册拾取器(UIActionSheet, UIAler...
iOS 自定义弹出菜单 UIMenuBar ,UIMenuBar 是一个 iOS 自定义弹出菜单,用于替换内置的 UIActionSheet,支持...
前两年IOS应用源码-主要是用于毕业设计学习的。
仿UIAlertView和UIActionSheet的一个效果.zipIOS应用例子源码下载仿UIAlertView和UIActionSheet的一个效果.zipIOS应用例子源码下载 1.适合学生学习研究参考 2.适合个人学习研究参考 3.适合公司开发项目技术参考
简单的自定义UIActionSheet
IOS应用源码之仿UIAlertView和UIActionSheet的一个效果 .rar
IOS应用源码——仿UIAlertView和UIActionSheet的一个效果.zip
多功能选择器UIActionSheet,仿微信ActionSheet,还有其他样式改变,满足各种需求
将封装的UIActionSheet改为UIView,为了多态初始化时添加了枚举(几个时间选择器样式)。 UIActionSheet改为UIView核心代码为以下几个方法: - (void)showInView:(UIView *)view; // UIPicker显示 -(void)...
BlockAlertsAnd-ActionSheets, 出色的UIAlertView和UIActionSheet替换灵感由 TweetBot 它是如何启动的: A的故事。自从我第一次在应用中使用UIActionSheet或者UIAlertView时,我不喜欢它的实现方式。 如果在同一类中...