0% found this document useful (0 votes)
84 views3 pages

SDWeb Image Transition

This document defines an SDWebImageTransition class for adding transitions to image changes. It includes convenience methods to create different types of transitions like fade, flip, and curl transitions. The transitions are implemented using Core Animation transitions on iOS and macOS.

Uploaded by

istv4n
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
84 views3 pages

SDWeb Image Transition

This document defines an SDWebImageTransition class for adding transitions to image changes. It includes convenience methods to create different types of transitions like fade, flip, and curl transitions. The transitions are implemented using Core Animation transitions on iOS and macOS.

Uploaded by

istv4n
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

/*

* This file is part of the SDWebImage package.


* (c) Olivier Poitrey <rs@[Link]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

#import "SDWebImageTransition.h"

#if SD_UIKIT || SD_MAC

#if SD_MAC
#import <QuartzCore/QuartzCore.h>
#endif

@implementation SDWebImageTransition

- (instancetype)init {
self = [super init];
if (self) {
[Link] = 0.5;
}
return self;
}

@end

@implementation SDWebImageTransition (Conveniences)

+ (SDWebImageTransition *)fadeTransition {
SDWebImageTransition *transition = [SDWebImageTransition new];
#if SD_UIKIT
[Link] = UIViewAnimationOptionTransitionCrossDissolve |
UIViewAnimationOptionAllowUserInteraction;
#else
[Link] = ^(__kindof NSView * _Nonnull view, NSImage * _Nullable
image) {
CATransition *trans = [CATransition animation];
[Link] = kCATransitionFade;
[[Link] addAnimation:trans forKey:kCATransition];
};
#endif
return transition;
}

+ (SDWebImageTransition *)flipFromLeftTransition {
SDWebImageTransition *transition = [SDWebImageTransition new];
#if SD_UIKIT
[Link] = UIViewAnimationOptionTransitionFlipFromLeft |
UIViewAnimationOptionAllowUserInteraction;
#else
[Link] = ^(__kindof NSView * _Nonnull view, NSImage * _Nullable
image) {
CATransition *trans = [CATransition animation];
[Link] = kCATransitionPush;
[Link] = kCATransitionFromLeft;
[[Link] addAnimation:trans forKey:kCATransition];
};
#endif
return transition;
}

+ (SDWebImageTransition *)flipFromRightTransition {
SDWebImageTransition *transition = [SDWebImageTransition new];
#if SD_UIKIT
[Link] = UIViewAnimationOptionTransitionFlipFromRight |
UIViewAnimationOptionAllowUserInteraction;
#else
[Link] = ^(__kindof NSView * _Nonnull view, NSImage * _Nullable
image) {
CATransition *trans = [CATransition animation];
[Link] = kCATransitionPush;
[Link] = kCATransitionFromRight;
[[Link] addAnimation:trans forKey:kCATransition];
};
#endif
return transition;
}

+ (SDWebImageTransition *)flipFromTopTransition {
SDWebImageTransition *transition = [SDWebImageTransition new];
#if SD_UIKIT
[Link] = UIViewAnimationOptionTransitionFlipFromTop |
UIViewAnimationOptionAllowUserInteraction;
#else
[Link] = ^(__kindof NSView * _Nonnull view, NSImage * _Nullable
image) {
CATransition *trans = [CATransition animation];
[Link] = kCATransitionPush;
[Link] = kCATransitionFromTop;
[[Link] addAnimation:trans forKey:kCATransition];
};
#endif
return transition;
}

+ (SDWebImageTransition *)flipFromBottomTransition {
SDWebImageTransition *transition = [SDWebImageTransition new];
#if SD_UIKIT
[Link] = UIViewAnimationOptionTransitionFlipFromBottom |
UIViewAnimationOptionAllowUserInteraction;
#else
[Link] = ^(__kindof NSView * _Nonnull view, NSImage * _Nullable
image) {
CATransition *trans = [CATransition animation];
[Link] = kCATransitionPush;
[Link] = kCATransitionFromBottom;
[[Link] addAnimation:trans forKey:kCATransition];
};
#endif
return transition;
}

+ (SDWebImageTransition *)curlUpTransition {
SDWebImageTransition *transition = [SDWebImageTransition new];
#if SD_UIKIT
[Link] = UIViewAnimationOptionTransitionCurlUp |
UIViewAnimationOptionAllowUserInteraction;
#else
[Link] = ^(__kindof NSView * _Nonnull view, NSImage * _Nullable
image) {
CATransition *trans = [CATransition animation];
[Link] = kCATransitionReveal;
[Link] = kCATransitionFromTop;
[[Link] addAnimation:trans forKey:kCATransition];
};
#endif
return transition;
}

+ (SDWebImageTransition *)curlDownTransition {
SDWebImageTransition *transition = [SDWebImageTransition new];
#if SD_UIKIT
[Link] = UIViewAnimationOptionTransitionCurlDown |
UIViewAnimationOptionAllowUserInteraction;
#else
[Link] = ^(__kindof NSView * _Nonnull view, NSImage * _Nullable
image) {
CATransition *trans = [CATransition animation];
[Link] = kCATransitionReveal;
[Link] = kCATransitionFromBottom;
[[Link] addAnimation:trans forKey:kCATransition];
};
#endif
return transition;
}

@end

#endif

You might also like