在滚动ScrollView时,将UIImageView移动到A点到B点

时间:2015-09-04 19:44:42

标签: ios objective-c uiscrollview uiimageview

我正在尝试在UIPageViewController中执行自定义指示器检测滚动事件,并在Scrollview滚动时将指示符(UIImageView)从位置x 0移动到位置x 15

 -(void)scrollViewDidScroll:(UIScrollView *)scrollView {
    [self.imgIndicador setTranslatesAutoresizingMaskIntoConstraints:YES]; //respeita o frame que eu setar, independentemente das constraints

    CGRect alvo = self.pageControl.frame;
    CGFloat posicaoInicial = self.pageControl.frame.origin.x;
    CGFloat posicaoFinal = alvo.origin.x + alvo.size.width;
    if(scrollView.contentOffset.x < posicaoFinal) {
        [self.imgIndicador setFrame:CGRectMake(self.imgIndicador.frame.origin.x + scrollView.contentOffset.x/3.34, self.imgIndicador.frame.origin.y, self.imgIndicador.frame.size.width, self.imgIndicador.frame.size.height)];
    }

    NSLog(@"scrollou %f", scrollView.contentOffset.x);


}

0 个答案:

没有答案