AutoLayout中使用私有API _autolayoutTrace检查constraints

在ViewController.m中增加

@interface UIWindow (AutoLayoutDebug)
+ (UIWindow *)keyWindow;
- (NSString *)_autolayoutTrace;
@end
//方法
- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    NSLog(@"%@", [[UIWindow keyWindow] _autolayoutTrace]);
}

- (void)didRotateFromInterfaceOrientation:
(UIInterfaceOrientation)fromInterfaceOrientation
{
    [super didRotateFromInterfaceOrientation:
     fromInterfaceOrientation];
    NSLog(@"%@", [[UIWindow keyWindow] _autolayoutTrace]);
}

即可在输出中查看

你可能感兴趣的:(AutoLayout中使用私有API _autolayoutTrace检查constraints)