I have a picture. I have a program for iPhone. How to write a method that would set a picture (class UIImage ) on top of everything else?
Note: you need to fill the entire screen with a picture.
I have a picture. I have a program for iPhone. How to write a method that would set a picture (class UIImage ) on top of everything else?
Note: you need to fill the entire screen with a picture.
Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .
If I understand the question correctly:
UIImageView *imageView = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds]; imageView.image = myImage; [self.view addSubview:imageView]; view ? - Gralexпродолжение ниже - Max Mikheyenkoвесь экран picture, and received an answer using the size of the entire screen, not the controller. If it seems to you that it would be more correct to use the size of the parent controller view (and I do not say that I disagree with you on this) - write a comment or your answer. - Max Mikheyenko 1:53 pmUIScreen in which information about the screen is stored (the size of one point, the size of the screen). Take from there info to set the frame is fundamentally wrong. In that case, it probably led to the correct result, only because the view has borders like that of the screen . We need a full-screen : we set the boundaries of the parent view ( bounds ), we throw on this view . - GralexIf it is about how to bring the picture to the fore then:
CGRect rect = self.view.bounds; UIImage* myImage = [UIImage imageNamed:@"bla-bla.png"]; UIImageView *imageView = [[UIImageView alloc] initWithFrame:rect]; imageView.image = myImage; [self.view addSubview:imageView]; [self.view bringSubviewToFront:imageView]; You can add a subview on top of all controllers, in this case it will be a UIImageView with your image as a subview of a UIWindow through standard addSubiew.
UIImageView *imageView = [[UIImageView alloc] initWithImage:myImage]; MyAppDelegate* myDelegate = (((MyAppDelegate*) [UIApplication sharedApplication].delegate)); [myDelegate.window addSubview: imageView]; If you need right on top of everything, then it is better to do this:
[[UIApplication sharedApplication].windows.firstObject addSubview:imageView]
window level can lead to sad consequences. If you can not do this, it is better to do it in another way. - GralexSource: https://ru.stackoverflow.com/questions/575980/
All Articles