当前位置:   article > 正文

UI基础:UIActionSheet和UIAlterView_swift uialterview

swift uialterview

iOS系统中有提供了两个弹出视图的控件,分别是UIActionSheet和UIAlterView.效果图如下:

     

主要代码如下:

复制代码
 1 - (void)viewDidLoad {
 2     [super viewDidLoad];
 3     // Do any additional setup after loading the view, typically from a nib.
 4     UIButton * button1 = [UIButton buttonWithType:UIButtonTypeCustom];
 5     button1.frame = CGRectMake(100, 100, 100, 50);
 6     button1.backgroundColor = [UIColor cyanColor];
 7     [button1 addTarget:self action:@selector(onclick1:) forControlEvents:UIControlEventTouchUpInside];
 8     [self.view addSubview:button1];
 9     
10     UIButton * button2 = [UIButton buttonWithType:UIButtonTypeCustom];
11     button2.frame = CGRectMake(100 , 200, 100, 50);
12     button2.backgroundColor = [UIColor redColor];
13     [button2 addTarget:self action:@selector(onclick2:) forControlEvents:UIControlEventTouchUpInside];
14     [self.view addSubview:button2];
15 }
16 -(void)onclick1:(UIButton *)btn{
17     UIActionSheet * actionsheet = [[UIActionSheet alloc]initWithTitle:@"提示信息" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"确认" otherButtonTitles:nil];
18     [actionsheet showInView:self.view];
19 }
20 -(void)onclick2:(UIButton *)btn{
21     UIAlertView * alterView = [[UIAlertView alloc]initWithTitle:@"警告" message:@"您的言论违法中华人民共和国法律,有可能查你水表" delegate:self cancelButtonTitle:@"继续发表" otherButtonTitles:nil];
22     [alterView show];
23 }
复制代码
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/402799
推荐阅读
  

闽ICP备14008679号