適配 iOS 13 上 因 modalPresentationStyle 值變成了 UIModalPresentationPageSheet,導(dǎo)致之前通過(guò) presentViewController:animated:completion: 方法彈出的控制器效果非全屏的問(wèn)題
我是通過(guò) Category 和 Method Swizzling 的方式,當(dāng)設(shè)置 UIViewController 的 modalPresentationStyle 的時(shí)候,記錄下已經(jīng)設(shè)置過(guò)此值,當(dāng)調(diào)用 presentViewController:animated:completion: 方法的時(shí)候,判斷將要彈出的 UIViewController 是否設(shè)置過(guò) modalPresentationStyle 的值,如果沒(méi)有設(shè)置過(guò),并且 modalPresentationStyle 值為 UIModalPresentationPageSheet,則說(shuō)明是 iOS 13 中的默認(rèn)設(shè)置,在這種情況下,我把 modalPresentationStyle 值改為 UIModalPresentationFullScreen,然后再?gòu)棾隹刂破?,就可以解決在 iOS 13 彈出的控制器效果非全屏的問(wèn)題,同時(shí)也不影響之前設(shè)置過(guò) modalPresentationStyle 的控制器。