ios弹框

作者: 一个萝卜X个坑 | 来源:发表于2017-08-31 14:26 被阅读87次
    第一种
        
        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弹框

          本文链接:https://www.haomeiwen.com/subject/kkeqjxtx.html