0

基本上,我想要做的是检测用户何时在文本视图中滚动,然后隐藏标签(如果可能,平滑淡出)。(标签表示滚动以查看其余文本,但我不希望它在用户这样做后仍然显示。)

如果您可以在答案中包含 h/m 文件中使用的代码,我们将不胜感激。

更新代码以供将来参考:

。H

@interface myViewController : UIViewController

@property(nonatomic,retain) IBOutlet UILabel *label;

.m

@synthesize label;

- (void)scrollViewDidScroll:(UIScrollView *)textView
{
    [UIView animateWithDuration:1.0 animations:^{
        label.alpha = 0;
    }];
}

然后确保将 UITextView 委托设置为 self。

4

1 回答 1

0

您可以使用 UIScrollView 的委托方法– scrollViewDidScroll:来检测用户是否滚动,并使用 UIView 动画块淡出您的标签,如下所示:

[UIView animateWithDuration:1.0 animations:^{
    label.alpha = 0
}];
于 2012-12-07T13:54:53.873 回答