美文网首页
UIAlertController 文案居左,左对齐

UIAlertController 文案居左,左对齐

作者: innepeace | 来源:发表于2021-04-09 14:26 被阅读0次

    如题, UIAlertController 的文案居左显示,左对齐。代码如下

    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"温馨提示比较长" preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction *actionC = [UIAlertAction actionWithTitle:@"已确定并知悉该事项" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            [[NSUserDefaults standardUserDefaults] setValue:@"hadshow" forKey:@"showNotSupportFastRedeem"];
        }];
        // 设置左对齐
        ///设置左对齐
    //    UILabel *label1 = [alertVC.view valueForKeyPath:@"_titleLabel"];
        UILabel *label2 = [alertController.view valueForKeyPath:@"_messageLabel"];
        if (label2) {
    //    label1.textAlignment = NSTextAlignmentLeft;
            label2.textAlignment = NSTextAlignmentLeft;
        }
        
        [alertController addAction:actionC];
        [self presentViewController:alertController animated:YES completion:nil];
    

    相关文章

      网友评论

          本文标题:UIAlertController 文案居左,左对齐

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