分页期间的iOS FadeIn / FadeOut

时间:2015-03-12 18:57:53

标签: ios uiscrollview fade

我有一个内部视图的UIScrollView,我可以水平滚动。在滚动过程中,我想在屏幕上添加一个淡出效果,并在屏幕上显示淡入淡出。

这是我的代码:

 for (int i = 0; i <textEntries.count; i++)
    {
        CGRect frame;
        frame.origin.x = self.scrollView.frame.size.width * i + 5;
        frame.size.width = self.scrollView.frame.size.width - 10;
        frame.size.height = self.scrollView.frame.size.height - 10;
        self.scrollView.pagingEnabled = YES;

        UIView *subview = [[UIView alloc] initWithFrame:frame];
        if([[colorEntries objectAtIndex:i] isEqualToString:@"violet"]){
            subview.backgroundColor = [UIColor colorWithRed:(147/255.0) green:(90/255.0) blue:(255/255.0) alpha:1];
        } else {
            subview.backgroundColor = [UIColor colorWithRed:(100/255.0) green:(166/255.0) blue:(255/255.0) alpha:1];
        }
        subview.layer.cornerRadius = 5;
        [self.scrollView addSubview:subview];

        UITextView *noteLabel = [[UITextView alloc] init];
        noteLabel.frame = CGRectMake(0, 0, self.scrollView.frame.size.width - 20, self.scrollView.frame.size.height -20);
        noteLabel.text = [textEntries objectAtIndex:i];
        noteLabel.userInteractionEnabled = NO;
        noteLabel.backgroundColor = [UIColor clearColor];
        noteLabel.contentInset = UIEdgeInsetsMake(20,20,20,20);
        noteLabel.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:40];
        [noteLabel setTextColor:[UIColor whiteColor]];
        [subview addSubview:noteLabel];
        [noteLabel addObserver:self forKeyPath:@"contentSize" options:(NSKeyValueObservingOptionNew) context:NULL];


    }

你能帮我构建这个fadeIn / FadeOut效果吗? 谢谢!

0 个答案:

没有答案