【发布时间】:2018-02-07 02:30:32
【问题描述】:
我有一个 TDHomeCollectionHeaderView,我在它的initWithFrame 中设置了 zposition=-999。但是我发现在 drawRect 中 zPosition 是 1。发生了什么?什么改变了我的图层位置? TDHomeCollectionHeaderView 是 UICollectionView 的 SupplementaryView。
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self addSubview:self.imageView];
[self addSubview:self.iconView];
[self addSubview:self.label];
self.userInteractionEnabled = NO;
self.layer.zPosition = -999;
}
return self;
}
-(void)drawRect:(CGRect)rect
{
//here zposition is 1
NSLog(@"TDHomeCollectionHeaderView %f",self.layer.zPosition);
}
【问题讨论】:
-
//这里zposition为0 NSLog(@"TDHomeCollectionHeaderView %f",self.layer.zPosition);
-
@JRB 这里 zposition 是 1
标签: ios objective-c layer z-order