Bringing a subview to be in front of all other views

前端 未结 8 1910
走了就别回头了
走了就别回头了 2020-12-07 13:24

I am working on integrating an ad provider into my app currently. I wish to place a fading message in front of the ad when the ad displays but have been completely unsuccess

8条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-07 13:32

    Swift 2 version of Jere's answer:

    UIApplication.sharedApplication().keyWindow!.bringSubviewToFront(YourViewHere)
    

    Swift 3:

    UIApplication.shared.keyWindow!.bringSubview(toFront: YourViewHere)
    

    Swift 4:

    UIApplication.shared.keyWindow!.bringSubviewToFront(YourViewHere)
    

    Hope it saves someone 10 seconds! ;)

提交回复
热议问题