### CocoaPods Installation (Dynamic Framework) Source: https://github.com/indulgein/ybimagebrowser/blob/master/Pods/SDWebImage/README.md If not using static frameworks, this configuration uses 'use_frameworks!' to install SDWebImage as a dynamic framework. ```ruby platform :ios, '8.0' use_frameworks! pod 'SDWebImage' ``` -------------------------------- ### Carthage Installation Source: https://github.com/indulgein/ybimagebrowser/blob/master/Pods/SDWebImage/README.md Add the SDWebImage repository to your Cartfile for installation with Carthage. Note that Carthage builds all components. ```bash github "SDWebImage/SDWebImage" ``` -------------------------------- ### CocoaPods Subspec Installation Source: https://github.com/indulgein/ybimagebrowser/blob/master/Pods/SDWebImage/README.md Install specific SDWebImage modules, such as 'MapKit', by specifying the subspec in your Podfile. ```ruby pod 'SDWebImage/MapKit' ``` -------------------------------- ### CocoaPods Installation (Basic) Source: https://github.com/indulgein/ybimagebrowser/blob/master/Pods/SDWebImage/README.md Standard installation for iOS projects using CocoaPods. Ensure your platform is set to iOS 8.0 or higher. ```ruby platform :ios, '8.0' pod 'SDWebImage', '~> 5.0' ``` -------------------------------- ### CocoaPods Installation (Swift Static Framework) Source: https://github.com/indulgein/ybimagebrowser/blob/master/Pods/SDWebImage/README.md For Swift projects using CocoaPods 1.5.0+ and Xcode 9+, this allows SDWebImage to be used as a static framework without 'use_frameworks!'. Uncomment 'use_modular_headers!' if needed. ```ruby platform :ios, '8.0' # Uncomment the next line when you want all Pods as static framework # use_modular_headers! pod 'SDWebImage', :modular_headers => true ``` -------------------------------- ### Check WebP Support Source: https://github.com/indulgein/ybimagebrowser/blob/master/Pods/YYImage/README.md Verify if the WebP subspec is installed correctly in your project by calling the `YYImageWebPAvailable()` function. This is crucial for displaying WebP images. ```Objective-C YYImageWebPAvailable(); ``` -------------------------------- ### Control Animation Playback Source: https://github.com/indulgein/ybimagebrowser/blob/master/Pods/YYImage/README.md Manage the animation playback of a YYAnimatedImageView by stopping, starting, setting the current frame index, and checking the playing state. Properties like `currentAnimatedImageIndex` and `currentIsPlayingAnimation` support KVO. ```Objective-C YYAnimatedImageView *imageView = ...; // 暂停: [imageView stopAnimating]; // 播放: [imageView startAnimating]; // 设置播放进度: imageView.currentAnimatedImageIndex = 12; // 获取播放状态: image.currentIsPlayingAnimation; //上面两个属性都支持 KVO。 ``` -------------------------------- ### Load Image with Placeholder (Objective-C) Source: https://github.com/indulgein/ybimagebrowser/blob/master/Pods/SDWebImage/README.md Use this snippet to load an image from a URL and display a placeholder image while it loads. Requires importing SDWebImage. ```objective-c #import ... [imageView sd_setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"] placeholderImage:[UIImage imageNamed:@"placeholder.png"]]; ``` -------------------------------- ### Load Image with Placeholder (Swift) Source: https://github.com/indulgein/ybimagebrowser/blob/master/Pods/SDWebImage/README.md Use this Swift snippet to load an image from a URL and display a placeholder image while it loads. Requires importing SDWebImage. ```swift import SDWebImage imageView.sd_setImage(with: URL(string: "http://www.domain.com/path/to/image.jpg"), placeholderImage: UIImage(named: "placeholder.png")) ``` -------------------------------- ### Import SDWebImage Header Source: https://github.com/indulgein/ybimagebrowser/blob/master/Pods/SDWebImage/README.md Import the main umbrella header file in your Objective-C source files to use the SDWebImage library. ```objectivec #import ``` -------------------------------- ### Basic Usage: Image and Video Data Sources Source: https://github.com/indulgein/ybimagebrowser/blob/master/README.md Initialize YBImageBrowser with an array of data sources, including local images, network images, and videos. Set the current page and display the browser. ```Objective-C // Local image YBIBImageData *data0 = [YBIBImageData new]; data0.imageName = ...; data0.projectiveView = ...; // Network image YBIBImageData *data1 = [YBIBImageData new]; data1.imageURL = ...; data1.projectiveView = ...; // Video YBIBVideoData *data2 = [YBIBVideoData new]; data2.videoURL = ...; data2.projectiveView = ...; YBImageBrowser *browser = [YBImageBrowser new]; browser.dataSourceArray = @[data0, data1, data2]; browser.currentPage = ...; [browser show]; ``` -------------------------------- ### Swift Package Manager Dependency Source: https://github.com/indulgein/ybimagebrowser/blob/master/Pods/SDWebImage/README.md Declare SDWebImage as a dependency in your Package.swift file for use with Swift Package Manager. Specify the version range. ```swift let package = Package( // 5.1.0 ..< 6.0.0 dependencies: [ .package(url: "https://github.com/SDWebImage/SDWebImage.git", from: "5.1.0") ], // ... ) ``` -------------------------------- ### Display Animated Image (GIF) Source: https://github.com/indulgein/ybimagebrowser/blob/master/Pods/YYImage/README.md Use `YYImage` to load an animated GIF and display it using `YYAnimatedImageView`. Ensure the image file is correctly named. ```objective-c // File: ani@3x.gif UIImage *image = [YYImage imageNamed:@"ani.gif"]; UIImageView *imageView = [[YYAnimatedImageView alloc] initWithImage:image]; [self.view addSubView:imageView]; ``` -------------------------------- ### Progressive Image Decoding Source: https://github.com/indulgein/ybimagebrowser/blob/master/Pods/YYImage/README.md Implement progressive image decoding to display images as they download. This involves updating the decoder with new data chunks and rendering frames as they become available. ```Objective-C // 渐进式图片解码 (可用于图片下载显示): NSMutableData *data = [NSMutableData new]; YYImageDecoder *decoder = [[YYImageDecoder alloc] initWithScale:2.0]; while(newDataArrived) { [data appendData:newData]; [decoder updateData:data final:NO]; if (decoder.frameCount > 0) { UIImage image = [decoder frameAtIndex:0 decodeForDisplay:YES].image; // progressive display... } } [decoder updateData:data final:YES]; UIImage image = [decoder frameAtIndex:0 decodeForDisplay:YES].image; // final display... ``` -------------------------------- ### Play Frame Animation Source: https://github.com/indulgein/ybimagebrowser/blob/master/Pods/YYImage/README.md Create and play frame-based animations using an array of image paths and their corresponding durations. This is useful for sequences of images forming an animation. ```Objective-C // 文件: frame1.png, frame2.png, frame3.png NSArray *paths = @[@"/ani/frame1.png", @"/ani/frame2.png", @"/ani/frame3.png"]; NSArray *times = @[@0.1, @0.2, @0.1]; UIImage *image = [YYFrameImage alloc] initWithImagePaths:paths frameDurations:times repeats:YES]; UIImageView *imageView = [YYAnimatedImageView alloc] initWithImage:image]; [self.view addSubView:imageView]; ``` -------------------------------- ### Display Frame Animation Source: https://github.com/indulgein/ybimagebrowser/blob/master/Pods/YYImage/README.md Create a frame-based animation using an array of image paths and corresponding frame durations. This is useful for sequences of images that form an animation. ```objective-c // Files: frame1.png, frame2.png, frame3.png NSArray *paths = @[@"/ani/frame1.png", @"/ani/frame2.png", @"/ani/frame3.png"]; NSArray *times = @[@0.1, @0.2, @0.1]; UIImage *image = [YYFrameImage alloc] initWithImagePaths:paths frameDurations:times repeats:YES]; UIImageView *imageView = [YYAnimatedImageView alloc] initWithImage:image]; [self.view addSubView:imageView]; ``` -------------------------------- ### Progressive Image Decoding Source: https://github.com/indulgein/ybimagebrowser/blob/master/Pods/YYImage/README.md Implement progressive decoding for images where data arrives incrementally. The decoder can be updated with new data, and intermediate frames can be displayed as they become available. ```objective-c // Progressive: NSMutableData *data = [NSMutableData new]; YYImageDecoder *decoder = [[YYImageDecoder alloc] initWithScale:2.0]; while(newDataArrived) { [data appendData:newData]; [decoder updateData:data final:NO]; if (decoder.frameCount > 0) { UIImage image = [decoder frameAtIndex:0 decodeForDisplay:YES].image; // progressive display... } } [decoder updateData:data final:YES]; UIImage image = [decoder frameAtIndex:0 decodeForDisplay:YES].image; // final display... ``` -------------------------------- ### Display Animated Image Source: https://github.com/indulgein/ybimagebrowser/blob/master/Pods/YYImage/README.md Use YYImage to load and display animated images like GIFs in a UIImageView. Ensure the image file is correctly referenced. ```Objective-C UIImage *image = [YYImage imageNamed:@"ani.gif"]; UIImageView *imageView = [[YYAnimatedImageView alloc] initWithImage:image]; [self.view addSubView:imageView]; ``` -------------------------------- ### Manually Encode WebP Image Source: https://github.com/indulgein/ybimagebrowser/blob/master/Pods/YYImage/README.md Add images with specified durations to a WebP encoder and then encode them into NSData. ```Objective-C [webpEncoder addImage:image0 duration:0.1]; [webpEncoder addImage:image1 duration:0.15]; [webpEncoder addImage:image2 duration:0.2]; NSData webpData = [webpEncoder encode]; ``` -------------------------------- ### Detect Image Type from Data Source: https://github.com/indulgein/ybimagebrowser/blob/master/Pods/YYImage/README.md Detects the image type from raw image data. Use this when you have NSData and need to determine if it's a PNG, JPEG, GIF, or WebP. ```Objective-C NSData webpData = [webpEncoder encode]; // Get image type from image data YYImageType type = YYImageDetectType(data); if (type == YYImageTypePNG) ... ``` -------------------------------- ### Animation Control for YYAnimatedImageView Source: https://github.com/indulgein/ybimagebrowser/blob/master/Pods/YYImage/README.md Control the playback of animations on a `YYAnimatedImageView` instance. Methods are provided to pause, play, set the current frame index, and check the animation status. ```objective-c YYAnimatedImageView *imageView = ...; // pause: [imageView stopAnimating]; // play: [imageView startAnimating]; // set frame index: imageView.currentAnimatedImageIndex = 12; // get current status image.currentIsPlayingAnimation; ``` -------------------------------- ### Encode Animated Image Source: https://github.com/indulgein/ybimagebrowser/blob/master/Pods/YYImage/README.md Encode multiple `UIImage` objects into an animated image format such as WebP. Each image can have a specified duration, and the encoder can be configured with a loop count. ```objective-c // Encode animated image: YYImageEncoder *webpEncoder = [[YYImageEncoder alloc] initWithType:YYImageTypeWebP]; webpEncoder.loopCount = 5; [webpEncoder addImage:image0 duration:0.1]; [webpEncoder addImage:image1 duration:0.15]; [webpEncoder addImage:image2 duration:0.2]; ``` -------------------------------- ### Display Sprite Sheet Animation Source: https://github.com/indulgein/ybimagebrowser/blob/master/Pods/YYImage/README.md Animate using a sprite sheet by defining content rectangles and frame durations for each sprite. This method is efficient for animations composed of many small frames within a single image. ```objective-c // 8 * 12 sprites in a single sheet image UIImage *spriteSheet = [UIImage imageNamed:@"sprite-sheet"]; NSMutableArray *contentRects = [NSMutableArray new]; NSMutableArray *durations = [NSMutableArray new]; for (int j = 0; j < 12; j++) { for (int i = 0; i < 8; i++) { CGRect rect; rect.size = CGSizeMake(img.size.width / 8, img.size.height / 12); rect.origin.x = img.size.width / 8 * i; rect.origin.y = img.size.height / 12 * j; [contentRects addObject:[NSValue valueWithCGRect:rect]]; [durations addObject:@(1 / 60.0)]; } } YYSpriteSheetImage *sprite; sprite = [[YYSpriteSheetImage alloc] initWithSpriteSheetImage:img contentRects:contentRects frameDurations:durations loopCount:0]; YYAnimatedImageView *imageView = [YYAnimatedImageView new]; imageView.size = CGSizeMake(img.size.width / 8, img.size.height / 12); imageView.image = sprite; [self.view addSubView:imageView]; ``` -------------------------------- ### Decode Single Frame Image Source: https://github.com/indulgein/ybimagebrowser/blob/master/Pods/YYImage/README.md Decode a single frame from an image file (e.g., WebP) using `YYImageDecoder`. The `decodeForDisplay` parameter optimizes the image for rendering. ```objective-c // Decode single frame: NSData *data = [NSData dataWithContentsOfFile:@"/tmp/image.webp"]; YYImageDecoder *decoder = [YYImageDecoder decoderWithData:data scale:2.0]; UIImage image = [decoder frameAtIndex:0 decodeForDisplay:YES].image; ``` -------------------------------- ### Decode Single Frame Image Source: https://github.com/indulgein/ybimagebrowser/blob/master/Pods/YYImage/README.md Decode a single frame from an image file, such as a WebP image, using YYImageDecoder. This is useful for displaying static images or specific frames from animated formats. ```Objective-C // 解码单帧图片: NSData *data = [NSData dataWithContentsOfFile:@"/tmp/image.webp"]; YYImageDecoder *decoder = [YYImageDecoder decoderWithData:data scale:2.0]; UIImage image = [decoder frameAtIndex:0 decodeForDisplay:YES].image; ``` -------------------------------- ### Encode Still Image Source: https://github.com/indulgein/ybimagebrowser/blob/master/Pods/YYImage/README.md Encode a `UIImage` into a still image format like JPEG using `YYImageEncoder`. The `quality` property can be set to control compression. ```objective-c // Encode still image: YYImageEncoder *jpegEncoder = [[YYImageEncoder alloc] initWithType:YYImageTypeJPEG]; jpegEncoder.quality = 0.9; [jpegEncoder addImage:image duration:0]; NSData jpegData = [jpegEncoder encode]; ``` -------------------------------- ### Encode Animated Image Source: https://github.com/indulgein/ybimagebrowser/blob/master/Pods/YYImage/README.md Encode animated image formats like GIF, APNG, and WebP using YYImageEncoder. You can specify the loop count for the animation. ```Objective-C // 编码动态图 (支持 GIF/APNG/WebP): YYImageEncoder *webpEncoder = [[YYImageEncoder alloc] initWithType:YYImageTypeWebP]; webpEncoder.loopCount = 5; ``` -------------------------------- ### Detect Image Type Source: https://github.com/indulgein/ybimagebrowser/blob/master/Pods/YYImage/README.md Detect the image type from NSData using YYImageDetectType. ```Objective-C // 获取图片类型 YYImageType type = YYImageDetectType(data); if (type == YYImageTypePNG) ... ``` -------------------------------- ### Encode Static Image Source: https://github.com/indulgein/ybimagebrowser/blob/master/Pods/YYImage/README.md Encode various common image formats, such as JPEG, into NSData using YYImageEncoder. You can control encoding quality and add images with specified durations. ```Objective-C // 编码静态图 (支持各种常见图片格式): YYImageEncoder *jpegEncoder = [[YYImageEncoder alloc] initWithType:YYImageTypeJPEG]; jpegEncoder.quality = 0.9; [jpegEncoder addImage:image duration:0]; NSData jpegData = [jpegEncoder encode]; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.