简体   繁体   中英

how can i modify contentInset as my animation is going?

I would like to modify my contentInset to the origin of a label that is animating as it is animating ( i'm lowering a label and i would like to scroll the view to the label's origin as it is animating so that it looks like it is staying still )

You can add both animations in one block like this:

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:<#duration#>];

    [<#yourLabel#> setFrame:CGRectMake(<#CGFloat x#>, <#CGFloat y#>, <#CGFloat width#>, <#CGFloat height#>)];
    [<#yourScrollView#> setContentInset:UIEdgeInsetsMake(<#CGFloat top#>, <#CGFloat left#>, <#CGFloat bottom#>, <#CGFloat right#>)];

    [UIView commitAnimations];

Let me know if this works for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM