KoalaInjection 0.2.2

KoalaInjection 0.2.2

Oliver Letterer维护。



🐨KoalaInjection

邪恶但简单的代码注入,请勿使用!

示例

let view = UIView(frame: CGRect(x: 0.0, y: 0.0, width: 50.0, height: 50.0))
view.backgroundColor = UIColor.red

view.koala🐨.layoutSubviews {  // inject code after original implementation
    $0.backgroundColor = UIColor.blue
}

高级

• 提取参数

let viewController = UIViewController()

viewController.koala🐨.setTitle { 
    let title = $1.arguments()[0] as NSString
}

• 修改参数

let viewController = UIViewController()

viewController.koala🐨.before.viewWillDisappear { 
    $1.arguments()[0] = true
}

• 返回值

let viewController = UIViewController()

viewController.koala🐨.prefersStatusBarHidden { () -> Bool in 
    return Bool.random()
}

更改返回值

let viewController = UIViewController()
viewController.title = "Hello"

viewController.koala🐨.title { (_, _, result) -> NSString? in 
    return result?.appending(" world") as NSString?
}

作者

Oliver Letterer, [email protected]

许可

KoalaInjection遵循MIT许可。查看LICENSE文件以获取更多信息。