iOS: Why do I have white, rounded corners on my modal view?

前端 未结 9 802
悲哀的现实
悲哀的现实 2021-01-02 00:37

I have a modal view popping up in my iPad app and for some reason it has white, rounded corners.

It might be worth noting I built this model view in my storyboard, n

9条回答
  •  我在风中等你
    2021-01-02 01:00

    I realize this is an old question but it deserves an answer...

    On the iPad Modal views (using UIModalPresentationFormSheet) have a default background which is a white bordered image with whitish dog eared corners. Anyway the default background will show through if your modal view background has round or transparent corners.

    I spent a fair bit of time trying to figure out how to have my background view show without having the default background show. The trick is to make the superview smaller than your view:

    vc.view.clipsToBounds = NO;
    vc.view.superview.bounds = CGRectMake(vc.view.superview.bounds.origin.x, vc.view.superview.bounds.origin.y, 300, 480);
    

    NOTES: the vc is the view you are presenting. Don't make the view too small or else your touch event will not work.

提交回复
热议问题