iOS ScrollView上的view添加悬停效果

scrollView要设置代理代理

scrollView.delegate = self;it

 

//要悬停的viewscroll

UIView * hoverView = [[UIView alloc] initWithFrame:CGRectMake(x, y, width, height)];方法

 [scrollView addSubview:logoView];view

 

// 代理方法vi

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {co

//scrollView 的偏移量大于 ( 悬停view的纵坐标y - 状态栏的高度 STATUS_BAR_HEIGHT )时添加到与scrollView同一层级void

if (scrollView.contentOffset.y > y - STATUS_BAR_HEIGHT) {

            hoverView.frame = CGRectMake(0, STATUS_BAR_HEIGHT, width, height);

            [self.view addSubview:hoverView];

        }else {

            hoverView.frame = CGRectMake(0, y, width, height);

            [scrollView addSubview:hoverView];

        }

}

相关文章
相关标签/搜索