iOS 关于改变frame的问题

我在瀑布流(collectionview)上方加了一个view(红色那个,adview),现在问题是我一划动,就会直接到最底部,而且滑不上去了了_adView = [[UIView alloc] initWithFrame:CGRectMake(0, 64, self.view.frame.size.height, 250)];
_adView.backgroundColor = [UIColor redColor];
[self.view addSubview:_adView];
self.collectionView.frame = CGRectMake(0, _adView.frame.origin.y+_adView.frame.size.height, self.view.frame.size.width, self.view.frame.size.height - 294);
[self.view addSubview:self.collectionView];
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
CGPoint point=scrollView.contentOffset;
//NSLog(@"%f,%f",point.x,point.y);
CGRect frame = [_adView frame];
frame.origin.y = _adView.frame.origin.y-point.y;
if (frame.origin.y > 64) {
frame.origin.y = 64;
}
_adView.frame = frame;
//NSLog(@"我勒个去%f",_adView.frame.origin.y);
frame = [scrollView frame];
frame.origin.y = _collectionView.frame.origin.y-point.y;
if (frame.origin.y > 314) {
frame.origin.y = 314;
}
frame.size.height = self.view.frame.size.height - frame.origin.y - 44;
scrollView.frame = frame;
NSLog(@"哈哈%f",_collectionView.frame.size.height + _adView.frame.origin.y);
NSLog(@"我去,我去,我去");
}
图片说明

ios

1个回答

图片说明

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐