injectionForXcode代码注入步骤

2017-12-09  本文已影响20人  狂奔的兔子
import UIKit

extension UIViewController { //5
    
    #if DEBUG //1
    @objc func injected() { //2
        for subview in self.view.subviews { //3
            subview.removeFromSuperview()
        }      
        
        viewDidLoad() //4
    }
    #endif
}

如果有动画,使用如下代码

import UIKit

extension UIViewController {
    
    #if DEBUG
    @objc func injected() {
        
        for subview in self.view.subviews {
            subview.removeFromSuperview()
        }
        if let sublayers = self.view.layer.sublayers {
            for sublayer in sublayers {
                sublayer.removeFromSuperlayer()
            }
        }
        
        viewDidLoad()
    }
    #endif
}

原文链接

上一篇下一篇

猜你喜欢

热点阅读