新建一个UIView的分类,重写debugDescription方法
UIView+YYY.h
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface UIView (YYY)
@end
NS_ASSUME_NONNULL_END
UIView+YYY.m
#import "UIView+YYY.h"
@implementation UIView (YYY)
- (NSString *)debugDescription{
NSString *add = [NSString stringWithFormat:@"self.bounds = %@\n self.layer.bounds = %@\n self.layer.frame = %@\n description = %@",NSStringFromCGRect(self.bounds),NSStringFromCGRect(self.layer.bounds),NSStringFromCGRect(self.layer.frame),[super debugDescription]] ;
return add;
}
@end
这样在右键查看一个view的时候,打印的时候,打印的就是比较完全的信息
Printing description of $28:
self.bounds = {{0, 3.5}, {428, 865}}
self.layer.bounds = {{0, 3.5}, {428, 865}}
self.layer.frame = {{0, 30.5}, {428, 865}}
description = <UILayoutContainerView: 0x1445bf100; frame = (0 30.5; 428 865); autoresize = W+H; gestureRecognizers = <NSArray: 0x301b50e80>; layer = <CALayer: 0x305e9e8e0>>
可以看到 bounds 的 y改了,所以子视图的y 是 30.5 - 3.5 = 27