0

当我的 uiscrollview 中的 uiimage 滚动到某个点(例如 y 轴上的 100)时,如何使按钮消失(基本上只是透明),并在它再次向上滚动时再次出现。

简而言之,我希望当用户向下滚动超过某个点时按钮的不透明度变为 0,然后当它滚动回该点时不透明度恢复正常。

我到处寻找答案,但似乎没有什么与我相关,而且它不起作用,并且带有许多不同的警告。

提前致谢。

4

1 回答 1

1

问题解决了 !!!

1) 代表,

@interface ViewController ()<UIScrollViewDelegate>

2)设置委托

self.scrollView.delegate = self;

3)把这个委托方法,

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

    if(scrollView.contentOffset.y >100){
        if((int)self.button.layer.opacity==1){
            self.button.layer.opacity = 0;
        }
    }else{
        if((int)self.button.layer.opacity==0){
            self.button.layer.opacity = 1;
        }
    }

}

4)不要忘记,#import <QuartzCore/QuartzCore.h>因为你处理 button.layer

于 2013-05-11T15:05:50.070 回答