I wanted to put an image on top of the AlertController's title, so I researched the method.
I found the method below,
[alertController setValue:customController forKey:@"contentViewController"];
By configuring CustomController and calling [alertController setValue:customController forKey:@"contentViewController"];, I was able to expose it as I wanted in light mode.
However, in the dark mode state, the background of the AletController is well applied in the dark mode, but the text of the CustomController added to the contentViewController is always exposed in black like the light mode.
In CustomController, the text color is set to default(Lable Color).
When I was in Dark mode, I opened the AlertController and checked the userInterfaceStyle through traitCollectionDidChange in CustomController, and it was confirmed that Light mode was always delivered.
[DarkMode]
https://www.icloud.com/iclouddrive/04jjVAUe1zfXCdGOc9fMMAvLQ#Screen_Shot_2020-10-29_at_9.26.01_PM
[LightMode]
https://www.icloud.com/iclouddrive/0fgOdbrV0WCTCkB75ygmG5oqQ#Screen_Shot_2020-10-29_at_9.26.16_PM
Code
Code Block language UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleAlert]; UIViewController *v = [[UICustomViewController alloc] initWithTitle:@"Title message" content:@"content message" dismissCallback:^(NSError * _Nullable error) { }]; [alertController setValue:v forKey:@"contentViewController"]; UIAlertAction *somethingAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}]; UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {}]; [alertController addAction:somethingAction]; [alertController addAction:cancelAction]; [viewController presentViewController:alertController animated:YES completion:^{}];
Have you ever been wrong with the method I applied?
Is there any other way I can apply it like the attached image?