Date
Nov. 25th, 2024
 
2024年 10月 25日

Post: iOS: NSLayoutConstraint 动画

iOS: NSLayoutConstraint 动画

Published 12:10 Oct 20, 2014.

Created by @ezra. Categorized in #Programming, and tagged as #iOS.

Source format: Markdown

Table of Content

直接上代码:

// @implementation NSLayoutConstraint (Animation)
- (void)setConstant:(CGFloat)constant animatedDuration:(NSTimeInterval)duration {
    __weak typeof(self) weakSelf = self;
    [UIView animateWithDuration:duration animations:^{
        __strong typeof(weakSelf) strongSelf = weakSelf;
        [strongSelf setConstant:constant];
        if ([strongSelf.firstItem isMemberOfClass:[UIView class]]) {
            [((UIView *)strongSelf.firstItem) layoutIfNeeded];
        }
    }];
}
Pinned Message
HOTODOGO
The Founder and CEO of Infeca Technology.
Developer, Designer, Blogger.
Big fan of Apple, Love of colour.
Feel free to contact me.
反曲点科技创始人和首席执行官。
开发、设计与写作皆为所长。
热爱苹果、钟情色彩。
随时恭候 垂询