ios弹框

第一种
    
    UIAlertController *aler=[UIAlertController alertControllerWithTitle:@"温馨提示" message:@"确定取消?" preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *ok=[UIAlertAction actionWithTitle:@"确定取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
    }];
    UIAlertAction *cancel=[UIAlertAction actionWithTitle:@"暂不取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
           
    }];
    //设置按钮字体颜色
    [cancel setValue:[UIColor redColor] forKey:@"_titleTextColor"];
    [aler addAction:cancel];
    //添加
    [aler addAction:ok];
    //最后一步
    [self presentViewController:aler animated:YES completion:nil];
    

第二种


    UIAlertView*alert = [[UIAlertView alloc]initWithTitle:@"提示"
                                                  message:@"确定取消?"
                                                 delegate:self
                                        cancelButtonTitle:@"暂不取消"
                                        otherButtonTitles:@"确定取消",nil];
    [alert show];
    


代理方法

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    if (buttonIndex==1) {
    }
    NSLog(@"您按下的第%ld个按钮!",buttonIndex);
}

你可能感兴趣的:(ios弹框)