是否可以将 NSMutableArray 的内容转换为 std::vector ?如果是这样,应该在 Objective-C 或 C++ 代码中完成吗?
我正在尝试使用动作表样式创建UIAlertController,但我想将背景颜色更改为灰色.我已经能够找到一种方法来改变UIAlertController的背景颜色,但不能找到取消按钮."取消"按钮是独立的,保持白色.
这是我现在的代码:
UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
[alert addAction:[UIAlertAction actionWithTitle:@"Option 1" style:UIAlertActionStyleDefault handler:nil]];
[alert addAction:[UIAlertAction actionWithTitle:@"Option 2" style:UIAlertActionStyleDefault handler:nil]];
[alert addAction:[UIAlertAction actionWithTitle:@"Option 3" style:UIAlertActionStyleDefault handler:nil]];
[alert addAction:[UIAlertAction actionWithTitle:@"Delete" style:UIAlertActionStyleDestructive handler:nil]];
[alert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]];
UIView *firstSubview = alert.view.subviews.firstObject;
UIView *alertContentView = firstSubview.subviews.firstObject;
for (UIView *subSubView in alertContentView.subviews) {
subSubView.backgroundColor = [UIColor darkGrayColor]; // Here you change background
}
alert.view.tintColor = [UIColor whiteColor];
[self.controller presentViewController:alert animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
这给了我以下结果: 链接
我已经访问过如何更改UIAlertController的背景颜色? 但是没有一个解决方案具有"取消"按钮背景的自定义颜色.
任何帮助,将不胜感激!