Moving CALayer's mask on scroll in a Scrollview

后端 未结 1 1417
挽巷
挽巷 2021-02-14 02:23

I am experimenting with iOS SDK and I have the following UIView structure:

  • UIView
    • UIImageView - only a background i
相关标签:
1条回答
  • 2021-02-14 02:44

    CALayer are implicit animated for some properties like position try to disable them:

    - (void)scrollViewDidScroll:(UIScrollView *)scrollView
    {
    
    [CATransaction begin];
        [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
    CGPoint contentOffset = scrollView.contentOffset;
    contentOffset.y = -contentOffset.y;
    
    self.overlayImageView.viewlayer.mask.position = contentOffset;
    [CATransaction commit];
    
    }
    
    0 讨论(0)
提交回复
热议问题