ios access main window or view

前端 未结 4 1900
小蘑菇
小蘑菇 2021-02-07 05:12

I would like to know if there is a simple way to access the main window or view in IOS. Something similar to:

[UIScreen mainScreen]

Thank you.<

4条回答
  •  梦谈多话
    2021-02-07 05:13

    Simply clever, works from any class:

    [(YourAppDelegate *)[[UIApplication sharedApplication] delegate] window];
    

    Note: don't forget to import your appDelegate class

提交回复
热议问题