我的问题是关于约束的创建:为什么创建一系列稍后用该activate方法激活的约束比用 逐一激活更有效.isActive = true?
激活直接约束,我们基本上是在改变一个属性,一个已经在UIView我们正在修改的变量中实例化的变量:
@available(iOS 9.0, *)
open var topAnchor: NSLayoutYAxisAnchor { get }
Run Code Online (Sandbox Code Playgroud)
但定义表明使用数组更有效:
/* Convenience method that activates each constraint in the contained array, in the same manner as setting active=YES.
This is often more efficient than activating each constraint individually. */
@available(iOS 8.0, *)
open class func activate(_ constraints: [NSLayoutConstraint])
Run Code Online (Sandbox Code Playgroud)
我不知道如何创建已经在范围内的变量数组,然后将其传递到循环中以激活它。这如何比启用直接约束更有效?
我想通过代码定义状态栏的颜色,我发现它是这样的,但它已被弃用。有谁知道这样做的新方法是什么?这个警告在我的所有代码中都跟着我
这段代码可以工作,但有警告
任何想要的人的代码:
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
UIApplication.shared.statusBarStyle = UIStatusBarStyle.lightContent
return true
}
Run Code Online (Sandbox Code Playgroud)