gpt4 book ai didi

ios - 向下/向上滚动时淡出/显示 UIButton

转载 作者:行者123 更新时间:2023-12-02 12:12:32 24 4
gpt4 key购买 nike

我有一个 TableView 。 View 中是 UIButton。我想要什么时候向下滚动按钮淡出以及什么时候滚动停止或向上按钮显示。

enter image description here

代码:

- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView{
NSLog(@"Start scroll");

//I assume the buttons are within your cells so you will have to enable them within your cells so you will probably have to handle this by sending a custom message to your cells or accessing them with properties.
CGRect frame = addCommentBtn.frame;
frame.origin.y = scrollView.contentOffset.y + self.newsTableView.frame.size.height + 4;
addCommentBtn.frame = frame;

[self.view bringSubviewToFront:addCommentBtn];}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
NSLog(@"End scroll");

// do the same to enable them back
CGRect frame = addCommentBtn.frame;
frame.origin.y = scrollView.contentOffset.y + self.newsTableView.frame.size.height + 4;
addCommentBtn.frame = frame;

[self.view bringSubviewToFront:addCommentBtn];}

但无法正常工作!谢谢

最佳答案

您使用了错误的方法。代替scrollViewWillBeginDecelerating: 使用 scrollViewDidScroll: 并根据 ScrollView 的 contentOffset 更新按钮 alpha 和位置。

关于ios - 向下/向上滚动时淡出/显示 UIButton,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35676889/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com