您的位置:首页 > 产品设计 > UI/UE

UI基础:UIActionSheet和UIAlterView

2015-08-22 17:48 453 查看
iOS中有两个弹出视图的控件,分别是UIActionSheet和UIAlterView.效果图如下:





主要代码如下:

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIButton * button1 = [UIButton buttonWithType:UIButtonTypeCustom];
button1.frame = CGRectMake(100, 100, 100, 50);
button1.backgroundColor = [UIColor cyanColor];
[button1 addTarget:self action:@selector(onclick1:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button1];

UIButton * button2 = [UIButton buttonWithType:UIButtonTypeCustom];
button2.frame = CGRectMake(100 , 200, 100, 50);
button2.backgroundColor = [UIColor redColor];
[button2 addTarget:self action:@selector(onclick2:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button2];
}
-(void)onclick1:(UIButton *)btn{
UIActionSheet * actionsheet = [[UIActionSheet alloc]initWithTitle:@"提示信息" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"确认" otherButtonTitles:nil];
[actionsheet showInView:self.view];
}
-(void)onclick2:(UIButton *)btn{
UIAlertView * alterView = [[UIAlertView alloc]initWithTitle:@"警告" message:@"您的言论违法中华人民共和国法律,有可能查你水表" delegate:self cancelButtonTitle:@"继续发表" otherButtonTitles:nil];
[alterView show];
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: