我已经创建了一个如下所示的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。

我尝试这样获得标签:
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);我得到一个空数组

发布于 2017-04-11 12:19:46
您必须将masksToBounds设置为yes
deleteView.view.layer.cornerRadius = 15;
deleteView.view.layer.masksToBounds = YES;发布于 2020-03-27 11:08:38
在Sathya Baman的回答之后,添加以下行。背景颜色必须与alertView的当前背景相匹配。
alert.view.backgroundColor = .white发布于 2017-04-11 13:09:29
很简单,只需要做两行代码..
deleteView.view.layer.cornerRadius = 100;deleteView.view.layer.masksToBounds =是;
https://stackoverflow.com/questions/43336485
复制相似问题