ios - 如何更改 UIAlertController 的角半径

标签 ios objective-c uialertcontroller

我创建了一个像这样的 UIAlertController:

    UIAlertController deleteView = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleAlert];
    deleteView.view.layer.cornerRadius = 100;
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"delete" style:UIAlertActionStyleDefault handler:nil];
    [cancelAction setValue:[NSNumber numberWithInteger:NSTextAlignmentLeft] forKey:@"titleTextAlignment"];
    [cancelAction setValue:[UIColor blackColor] forKey:@"titleTextColor"];

我想更改操作标签的cornerRadius。

enter image description here

我尝试获取这样的标签:

  UIView *v1 = deleteView.view.subviews[0];
            UIView *v2 = v1.subviews[0];
            UIView *v3 = v2.subviews[0];
    UIView *v4 = v3.subviews[1].subviews[0].subviews[0];
            NSArray *arr = v5.subviews;
    NSArray *arr = v4.subviews;
    NSLog(@"v4:%@,arr:%@",v4,arr);

我得到一个空数组

enter image description here

最佳答案

您必须将 ma​​sksToBounds 设置为 yes

  deleteView.view.layer.cornerRadius = 15;
  deleteView.view.layer.masksToBounds = YES;

关于ios - 如何更改 UIAlertController 的角半径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43336485/

相关文章:

ios - 字符串中第一个和最后一个字符的范围

ios - 更改应用程序中所有 UIAlertController 的字体

iOS-8 及更高版本 - UIAlertController 内的 UITableView

ios - 如何在不重置 SCNNode 位置的情况下重置 SCNNode 的 SCNPhysicsBody?

ios - 可以以编程方式提供 iOS 预测键盘上下文/源文本吗?

ios - CVE-2015-5207 和 CVE-2015-5208 如何工作以及如何触发?

ios - 将 Objective C 协议(protocol)与 Swift 集成

ios - 序列化 JSON 而不用 [ ] 括起来

ios - UIAlertController 消息不会显示

ios - 修复弹出滚动菜单的动画