UI基础:UIActionSheet和UIAlterView

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

UI基础:UIActionSheet和UIAlterView_第1张图片     UI基础:UIActionSheet和UIAlterView_第2张图片

主要代码如下:

复制代码
 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 }
复制代码

你可能感兴趣的:(IOS,UIActionSheet,UIAlterView,ui,IOS)