I found the above to be less than robust, as the view structure seems to have changed.
This version is less sensitive to view order changes, and also caches the result for performance:
import ui
import objc_util
import ctypes
from functools import lru_cache
@lru_cache(maxsize=1)
def find_root_view():
"""
Locates the first `present`ed view.
"""
SUIView_PY3 = objc_util.ObjCClass('SUIView_PY3')
candidates = [objc_util.UIApplication.sharedApplication().windows()[0]]
while len(candidates) > 0:
objc_view = candidates.pop()
if objc_view.isKindOfClass_(SUIView_PY3.ptr):
return objc_view.pyObject(
argtypes=[], restype=ctypes.py_object)
candidates.extend(objc_view.subviews())
raise Exception('Root view not found')
v = ui.View(background='black')
v.present('fullscreen')
find_root_view().background_color = 'red'