iOS当遇到很奇特的页面的坐标问题时容易忽略的地方

新建一个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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值