Reputation: 546
When iOS presents an alert, the translucency is constant. When my app presents one, the alert is white at first, only for half a second, then it becomes translucent. It's a small issue, but it looks messy and alerts should be consistent everywhere I think. Anyways here is the code:
UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Invalid Credentials" message:@"Please try again." preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[_username becomeFirstResponder];
}];
[alertVC addAction:ok];
[self presentViewController:alertVC animated:YES completion:NULL];
I'm interested in people's opinions here as well. Is this just too small of an issue for anyone to be concerned about? It looks like this is just the way UIAlertController
works (at least when developers use it). Regardless, it looks messy and I would consider it a bug (unless I'm doing something wrong) since it doesn't look the same as when iOS presents an alert, even though it should.
Upvotes: 9
Views: 1046
Reputation: 349
For me the same issue is caused by flag "Renders with edge antialiasing" set to YES in Info.plist file. It was once set to improve simulator tableview rendering, and who knew that it affecting system alerts rendering on device.
Upvotes: 0
Reputation: 2431
Disclaimer: This is part opinion, part educated guess, and part experience.
The UIAlertController
has two main parts to it: the dark background and the message view. The dark background appears to be the very standard dark grey/black transparent view used for pop ups. The Message view looks to be using the same type of blur that's used for UIToolbar
and UINavigationController
.
The animation used for the transition for the UIAlertController
is a fade in on the dark background and a combination of fade and contract on the message view. Fading isn't that difficult to do with a blurred view; iOS generally just uses a transparent view and the snaps to a blurred view above an alpha
of 0.999
. That contracting animation though...that's where the magic is.
It's not just a frame resize, but the content of the message view actually changes size as well.
What's interesting about this is that instead of just resizing the frame of the message view and have the text fade in at a static size, someone at Apple decided to animate the text size changing as well to make it look like it's landing on the screen.
This label, button, and frame size changing combined with fading in a blur adds a fair amount of complexity to a rather simple view. So, instead of dealing with each separate issue, it looks like someone decided to use a snapshot of the view, animate the scale change and then "transition" to the desired look after the initial animation had completed.
As for why this isn't the case with messages directly in the OS...dog food.
Upvotes: 2