测试已测试 | ✗ |
Lang语言 | Obj-CObjective C |
许可证 | MIT |
Released上一个发布 | 2014年12月 |
由Fabio Knoedt维护。
一个非常简单的 UIView 子类,可以选择在 2+ 张图片之间像幻灯片一样动起来。
MyExample.m
@interface MyExample ()
@property (nonatomic, weak) IBOutlet YCSlideShowImageView *imageView;
@end
@implementation MyExample
- (void)aMethod {
/// Run in a loop of image URLs OR in a loop of stored images.
for (NSString *imageURL in _imageURLs) {
/// Here we start the download using AFNetworking (just an example). You can use any downloader.
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:imageURL]];
AFHTTPRequestOperation *requestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
requestOperation.responseSerializer = [AFImageResponseSerializer serializer];
[requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
/// Here we add each downloaded image to the Slide Show.
[_imageView addImage:image];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Image error: %@", error);
}];
[requestOperation start];
}
}
@end
如果您想重置动画,请调用:
[_imageView emptyImageArray];
有 3 个公开属性,您可以使用它们来自定义动画持续时间(animationDurationTime)、转换之间的延迟(animationDelay)以及动画的选项(animationOptions)。
CGFloat animationDurationTime;
CGFloat animationDelay;
UIViewAnimationOptions animationOptions;
在 iOS6+ 中运行良好,并支持 ARC。