How to animate uiscrollview scroll, with customized velocity, while calling the scrollviewdidscroll delegate?












1















Obviously there’s setContentOffset(animated) but this is way too slow, as the animation needs to be triggered by a swipe motion, similar to a pageviewcontroller. Because of that, there is an ugly delay from fast swipe to slow animation since I can’t change the animation speed of that function.



I tried UIView.animate and UIViewPropertyAnimator, trying to animate either the bounds or the content offset but nothing worked. The animation needs to be interruptible by another swipe, so uiview.animate couldn’t work, and uiviewpropertyanimator wouldn’t call scrollview delegate methods which I need to update other graphics.



The only thing that sort of works is a timer, set very fast but it’s stuttery and I know it’s not ideal to use a timer for animation.



Is there any way of animating a uiscrollview, interruptible, while calling scrollviewdidscroll along the way, with adjustable speed?










share|improve this question

























  • Don't quite understand your question since the view already performed some scrolling (after all, scrollViewDidScroll was called) but you want to animate scrolling on top of that?

    – FJ de Brienne
    Jan 3 at 1:29











  • I want to animate the view, with that delegate method being called along the way. (The animation should tigger the delegate)

    – Miles
    Jan 3 at 1:51











  • 1- Use a UIPanGestureRecognizer. 2- Don't attempt at animating during the panGesture, simply move the contentOffset to the new position, with iOS's refresh rate, nobody can tell and all system views do this. 3- If you want to do inertia panning on finger lift, use UIKit Dynamics to animate. 4- Call the scrollView delegate method during your pan gesture.

    – FJ de Brienne
    Jan 3 at 1:54
















1















Obviously there’s setContentOffset(animated) but this is way too slow, as the animation needs to be triggered by a swipe motion, similar to a pageviewcontroller. Because of that, there is an ugly delay from fast swipe to slow animation since I can’t change the animation speed of that function.



I tried UIView.animate and UIViewPropertyAnimator, trying to animate either the bounds or the content offset but nothing worked. The animation needs to be interruptible by another swipe, so uiview.animate couldn’t work, and uiviewpropertyanimator wouldn’t call scrollview delegate methods which I need to update other graphics.



The only thing that sort of works is a timer, set very fast but it’s stuttery and I know it’s not ideal to use a timer for animation.



Is there any way of animating a uiscrollview, interruptible, while calling scrollviewdidscroll along the way, with adjustable speed?










share|improve this question

























  • Don't quite understand your question since the view already performed some scrolling (after all, scrollViewDidScroll was called) but you want to animate scrolling on top of that?

    – FJ de Brienne
    Jan 3 at 1:29











  • I want to animate the view, with that delegate method being called along the way. (The animation should tigger the delegate)

    – Miles
    Jan 3 at 1:51











  • 1- Use a UIPanGestureRecognizer. 2- Don't attempt at animating during the panGesture, simply move the contentOffset to the new position, with iOS's refresh rate, nobody can tell and all system views do this. 3- If you want to do inertia panning on finger lift, use UIKit Dynamics to animate. 4- Call the scrollView delegate method during your pan gesture.

    – FJ de Brienne
    Jan 3 at 1:54














1












1








1


1






Obviously there’s setContentOffset(animated) but this is way too slow, as the animation needs to be triggered by a swipe motion, similar to a pageviewcontroller. Because of that, there is an ugly delay from fast swipe to slow animation since I can’t change the animation speed of that function.



I tried UIView.animate and UIViewPropertyAnimator, trying to animate either the bounds or the content offset but nothing worked. The animation needs to be interruptible by another swipe, so uiview.animate couldn’t work, and uiviewpropertyanimator wouldn’t call scrollview delegate methods which I need to update other graphics.



The only thing that sort of works is a timer, set very fast but it’s stuttery and I know it’s not ideal to use a timer for animation.



Is there any way of animating a uiscrollview, interruptible, while calling scrollviewdidscroll along the way, with adjustable speed?










share|improve this question
















Obviously there’s setContentOffset(animated) but this is way too slow, as the animation needs to be triggered by a swipe motion, similar to a pageviewcontroller. Because of that, there is an ugly delay from fast swipe to slow animation since I can’t change the animation speed of that function.



I tried UIView.animate and UIViewPropertyAnimator, trying to animate either the bounds or the content offset but nothing worked. The animation needs to be interruptible by another swipe, so uiview.animate couldn’t work, and uiviewpropertyanimator wouldn’t call scrollview delegate methods which I need to update other graphics.



The only thing that sort of works is a timer, set very fast but it’s stuttery and I know it’s not ideal to use a timer for animation.



Is there any way of animating a uiscrollview, interruptible, while calling scrollviewdidscroll along the way, with adjustable speed?







ios swift animation uiscrollview






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 3 at 9:14









Kaushik Makwana

955623




955623










asked Jan 2 at 21:07









MilesMiles

977




977













  • Don't quite understand your question since the view already performed some scrolling (after all, scrollViewDidScroll was called) but you want to animate scrolling on top of that?

    – FJ de Brienne
    Jan 3 at 1:29











  • I want to animate the view, with that delegate method being called along the way. (The animation should tigger the delegate)

    – Miles
    Jan 3 at 1:51











  • 1- Use a UIPanGestureRecognizer. 2- Don't attempt at animating during the panGesture, simply move the contentOffset to the new position, with iOS's refresh rate, nobody can tell and all system views do this. 3- If you want to do inertia panning on finger lift, use UIKit Dynamics to animate. 4- Call the scrollView delegate method during your pan gesture.

    – FJ de Brienne
    Jan 3 at 1:54



















  • Don't quite understand your question since the view already performed some scrolling (after all, scrollViewDidScroll was called) but you want to animate scrolling on top of that?

    – FJ de Brienne
    Jan 3 at 1:29











  • I want to animate the view, with that delegate method being called along the way. (The animation should tigger the delegate)

    – Miles
    Jan 3 at 1:51











  • 1- Use a UIPanGestureRecognizer. 2- Don't attempt at animating during the panGesture, simply move the contentOffset to the new position, with iOS's refresh rate, nobody can tell and all system views do this. 3- If you want to do inertia panning on finger lift, use UIKit Dynamics to animate. 4- Call the scrollView delegate method during your pan gesture.

    – FJ de Brienne
    Jan 3 at 1:54

















Don't quite understand your question since the view already performed some scrolling (after all, scrollViewDidScroll was called) but you want to animate scrolling on top of that?

– FJ de Brienne
Jan 3 at 1:29





Don't quite understand your question since the view already performed some scrolling (after all, scrollViewDidScroll was called) but you want to animate scrolling on top of that?

– FJ de Brienne
Jan 3 at 1:29













I want to animate the view, with that delegate method being called along the way. (The animation should tigger the delegate)

– Miles
Jan 3 at 1:51





I want to animate the view, with that delegate method being called along the way. (The animation should tigger the delegate)

– Miles
Jan 3 at 1:51













1- Use a UIPanGestureRecognizer. 2- Don't attempt at animating during the panGesture, simply move the contentOffset to the new position, with iOS's refresh rate, nobody can tell and all system views do this. 3- If you want to do inertia panning on finger lift, use UIKit Dynamics to animate. 4- Call the scrollView delegate method during your pan gesture.

– FJ de Brienne
Jan 3 at 1:54





1- Use a UIPanGestureRecognizer. 2- Don't attempt at animating during the panGesture, simply move the contentOffset to the new position, with iOS's refresh rate, nobody can tell and all system views do this. 3- If you want to do inertia panning on finger lift, use UIKit Dynamics to animate. 4- Call the scrollView delegate method during your pan gesture.

– FJ de Brienne
Jan 3 at 1:54












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54013202%2fhow-to-animate-uiscrollview-scroll-with-customized-velocity-while-calling-the%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54013202%2fhow-to-animate-uiscrollview-scroll-with-customized-velocity-while-calling-the%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

How to fix TextFormField cause rebuild widget in Flutter

in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith