<p align="center" >
<img src="https://raw.githubusercontent.com/SDWebImage/SDWebImage/master/SDWebImage_logo.png" title="SDWebImage logo" float=left>
</p>
[![Build Status](http://img.shields.io/travis/SDWebImage/SDWebImage/master.svg?style=flat)](https://travis-ci.org/SDWebImage/SDWebImage)
[![Pod Version](http://img.shields.io/cocoapods/v/SDWebImage.svg?style=flat)](http://cocoadocs.org/docsets/SDWebImage/)
[![Pod Platform](http://img.shields.io/cocoapods/p/SDWebImage.svg?style=flat)](http://cocoadocs.org/docsets/SDWebImage/)
[![Pod License](http://img.shields.io/cocoapods/l/SDWebImage.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0.html)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-brightgreen.svg)](https://github.com/SDWebImage/SDWebImage)
[![SwiftPM compatible](https://img.shields.io/badge/SwiftPM-compatible-brightgreen.svg)](https://swift.org/package-manager/)
[![Mac Catalyst compatible](https://img.shields.io/badge/Catalyst-compatible-brightgreen.svg)](https://developer.apple.com/documentation/xcode/creating_a_mac_version_of_your_ipad_app/)
[![codecov](https://codecov.io/gh/SDWebImage/SDWebImage/branch/master/graph/badge.svg)](https://codecov.io/gh/SDWebImage/SDWebImage)
This library provides an async image downloader with cache support. For convenience, we added categories for UI elements like `UIImageView`, `UIButton`, `MKAnnotationView`.
## Features
- [x] Categories for `UIImageView`, `UIButton`, `MKAnnotationView` adding web image and cache management
- [x] An asynchronous image downloader
- [x] An asynchronous memory + disk image caching with automatic cache expiration handling
- [x] A background image decompression to avoid frame rate drop
- [x] [Progressive image loading](https://github.com/SDWebImage/SDWebImage/wiki/Advanced-Usage#progressive-animation) (including animated image, like GIF showing in Web browser)
- [x] [Thumbnail image decoding](https://github.com/SDWebImage/SDWebImage/wiki/Advanced-Usage#thumbnail-decoding-550) to save CPU && Memory for large images
- [x] [Extendable image coder](https://github.com/SDWebImage/SDWebImage/wiki/Advanced-Usage#custom-coder-420) to support massive image format, like WebP
- [x] [Full-stack solution for animated images](https://github.com/SDWebImage/SDWebImage/wiki/Advanced-Usage#animated-image-50) which keep a balance between CPU && Memory
- [x] [Customizable and composable transformations](https://github.com/SDWebImage/SDWebImage/wiki/Advanced-Usage#transformer-50) can be applied to the images right after download
- [x] [Customizable and multiple caches system](https://github.com/SDWebImage/SDWebImage/wiki/Advanced-Usage#custom-cache-50)
- [x] [Customizable and multiple loaders system](https://github.com/SDWebImage/SDWebImage/wiki/Advanced-Usage#custom-loader-50) to expand the capabilities, like [Photos Library](https://github.com/SDWebImage/SDWebImagePhotosPlugin)
- [x] [Image loading indicators](https://github.com/SDWebImage/SDWebImage/wiki/How-to-use#use-view-indicator-50)
- [x] [Image loading transition animation](https://github.com/SDWebImage/SDWebImage/wiki/Advanced-Usage#image-transition-430)
- [x] A guarantee that the same URL won't be downloaded several times
- [x] A guarantee that bogus URLs won't be retried again and again
- [x] A guarantee that main thread will never be blocked
- [x] Modern Objective-C and better Swift support
- [x] Performances!
## Supported Image Formats
- Image formats supported by Apple system (JPEG, PNG, TIFF, HEIC, ...), including GIF/APNG/HEIC animation
- WebP format, including animated WebP (use the [SDWebImageWebPCoder](https://github.com/SDWebImage/SDWebImageWebPCoder) project). Note iOS 14/macOS 11.0 supports built-in WebP decoding (no encoding).
- Support extendable coder plugins for new image formats like BPG, AVIF. And vector format like PDF, SVG. See all the list in [Image coder plugin List](https://github.com/SDWebImage/SDWebImage/wiki/Coder-Plugin-List)
## Additional modules and Ecosystem
In order to keep SDWebImage focused and limited to the core features, but also allow extensibility and custom behaviors, during the 5.0 refactoring we focused on modularizing the library.
As such, we have moved/built new modules to [SDWebImage org](https://github.com/SDWebImage).
#### SwiftUI
[SwiftUI](https://developer.apple.com/xcode/swiftui/) is an innovative UI framework written in Swift to build user interfaces across all Apple platforms.
We support SwiftUI by building a brand new framework called [SDWebImageSwiftUI](https://github.com/SDWebImage/SDWebImageSwiftUI), which is built on top of SDWebImage core functions (caching, loading and animation).
The new framework introduce two View structs `WebImage` and `AnimatedImage` for SwiftUI world, `ImageIndicator` modifier for any View, `ImageManager` observable object for data source. Supports iOS 13+/macOS 10.15+/tvOS 13+/watchOS 6+ and Swift 5.1. Have a nice try and provide feedback!
#### Coders for additional image formats
- [SDWebImageWebPCoder](https://github.com/SDWebImage/SDWebImageWebPCoder) - coder for WebP format. iOS 8+/macOS 10.10+. Based on [libwebp](https://chromium.googlesource.com/webm/libwebp)
- [SDWebImageHEIFCoder](https://github.com/SDWebImage/SDWebImageHEIFCoder) - coder for HEIF format, iOS 8+/macOS 10.10+ support. Based on [libheif](https://github.com/strukturag/libheif)
- [SDWebImageBPGCoder](https://github.com/SDWebImage/SDWebImageBPGCoder) - coder for BPG format. Based on [libbpg](https://github.com/mirrorer/libbpg)
- [SDWebImageFLIFCoder](https://github.com/SDWebImage/SDWebImageFLIFCoder) - coder for FLIF format. Based on [libflif](https://github.com/FLIF-hub/FLIF)
- [SDWebImageAVIFCoder](https://github.com/SDWebImage/SDWebImageAVIFCoder) - coder for AVIF (AV1-based) format. Based on [libavif](https://github.com/AOMediaCodec/libavif)
- [SDWebImagePDFCoder](https://github.com/SDWebImage/SDWebImagePDFCoder) - coder for PDF vector format. Using built-in frameworks
- [SDWebImageSVGCoder](https://github.com/SDWebImage/SDWebImageSVGCoder) - coder for SVG vector format. Using built-in frameworks
- [SDWebImageLottieCoder](https://github.com/SDWebImage/SDWebImageLottieCoder) - coder for Lottie animation format. Based on [rlottie](https://github.com/Samsung/rlottie)
- and more from community!
#### Custom Caches
- [SDWebImageYYPlugin](https://github.com/SDWebImage/SDWebImageYYPlugin) - plugin to support caching images with [YYCache](https://github.com/ibireme/YYCache)
- [SDWebImagePINPlugin](https://github.com/SDWebImage/SDWebImagePINPlugin) - plugin to support caching images with [PINCache](https://github.com/pinterest/PINCache)
#### Custom Loaders
- [SDWebImagePhotosPlugin](https://github.com/SDWebImage/SDWebImagePhotosPlugin) - plugin to support loading images from Photos (using `Photos.framework`)
- [SDWebImageLinkPlugin](https://github.com/SDWebImage/SDWebImageLinkPlugin) - plugin to support loading images from rich link url, as well as `LPLinkView` (using `LinkPresentation.framework`)
#### Integration with 3rd party libraries
- [SDWebImageLottiePlugin](https://github.com/SDWebImage/SDWebImageLottiePlugin) - plugin to support [Lottie-iOS](https://github.com/airbnb/lottie-ios), vector animation rending with remote JSON files
- [SDWebImageSVGKitPlugin](https://github.com/SDWebImage/SDWebImageLottiePlugin) - plugin to support [SVGKit](https://github.com/SVGKit/SVGKit), SVG rendering using Core Animation, iOS 8+/macOS 10.10+ support
- [SDWebImageFLPlugin](https://github.com/SDWebImage/SDWebImageFLPlugin) - plugin to support [FLAnimatedImage](https://github.com/Flipboard/FLAnimatedImage) as the engine for animated GIFs
- [SDWebImageYYPlugin](https://github.com/SDWebImage/SDWebImageYYPlugin) - plugin to integrate [YYImage](https://github.com/ibireme/YYImage) & [YYCache](https://github.com/ibireme/YYCache) for image rendering & caching
#### Community driven popular libraries
- [FirebaseUI](https://github.com/firebase/FirebaseUI-iOS) -
iOS+HUD+加载LoadingHUD+MBProgressHUD使用
需积分: 0 197 浏览量
更新于2024-03-12
收藏 972KB ZIP 举报
在iOS应用开发中,用户界面的交互体验是至关重要的,特别是在执行耗时操作时,如网络请求、数据加载等。为了提高用户体验,开发者通常会使用HUD(Head-Up Display)组件来显示加载状态,如LoadingHUD和MBProgressHUD。这些组件提供了一种优雅的方式,向用户展示应用正在进行后台工作,并提示他们等待片刻。
MBProgressHUD是一款流行且易于使用的iOS HUD库,它提供了多种类型的加载动画,包括圆形进度条、活动指示器等。这个库允许开发者快速地在视图上添加一个加载提示,确保用户知道应用正在处理任务而不会感到困扰。下面我们将深入探讨MBProgressHUD的使用方法。
集成MBProgressHUD到项目中,你可以通过CocoaPods或手动导入库文件。如果你选择CocoaPods,只需在Podfile中添加以下行:
```ruby
pod 'MBProgressHUD'
```
然后运行`pod install`命令。手动导入则需将MBProgressHUD的源代码文件夹添加到Xcode项目中。
在使用MBProgressHUD之前,确保已经导入所需的头文件:
```swift
import MBProgressHUD
```
在你需要显示加载提示的地方,可以使用以下代码创建并显示一个MBProgressHUD:
```swift
let hud = MBProgressHUD.showAdded(to: view, animated: true)
hud.label.text = "加载中..."
```
这会在当前视图上显示一个圆形的加载动画,同时显示文本“加载中...”。
当你完成后台任务后,记得要隐藏MBProgressHUD:
```swift
hud.hide(animated: true)
```
MBProgressHUD还支持自定义显示样式和行为,例如改变颜色、设置模式(如指示器或定制视图)、添加子视图等。例如,如果你想显示一个带进度的加载条,可以这样做:
```swift
let hud = MBProgressHUD.showAdded(to: view, animated: true)
hud.mode = .determinate
hud.progress = 0.5 // 设置初始进度
```
在更新进度时,可以调用`setProgress(_:animated:)`方法:
```swift
hud.setProgress(0.8, animated: true)
```
此外,MBProgressHUD还提供了其他模式,如指示器模式(`.indeterminate`),用于显示持续的加载动画,以及自定义视图模式(`.customView`),允许你添加自己的视图作为加载指示器。
总结起来,MBProgressHUD是一个强大且灵活的工具,可以帮助开发者在iOS应用中实现专业级别的加载提示。它提供了多种加载样式和自定义选项,使得在应用中实现加载反馈变得简单易行。通过合理运用MBProgressHUD,不仅可以提升应用的用户体验,还能使应用看起来更加专业。在实际开发中,根据项目需求调整HUD的外观和行为,将使其成为提升应用质量的关键一环。
人若常清净天地悉皆归
- 粉丝: 0
- 资源: 2
最新资源
- 水果系统.rar
- 企业级新闻系统(SSH+MYSQL)130221.rar
- 图片浏览小程序(java+applet)130227.rar
- 通用的在线考试系统(jsp+struts+hibernate+oracle)130220.rar
- 微信文章爬虫项目全套技术资料100%好用.zip
- 单机无穷大系统发生各类(三相短路,单相接地,两相接地,两相相间短路)等短路故障,各类(单相断线,两相断线,三相断线)等断线故障,暂态稳定仿真分析
- 图书管理系统(struts+hibernate+spring).rar
- 图书管理系统(struts+hibernate+spring)130225.rar
- 图书管理系统(struts+hibernate+spring+ext).rar
- 网上订餐系统(struts+spring+hibernate).rar
- 网上订餐系统(struts+spring+hibernate)130221.rar
- 图书管理系统(struts+hibernate+spring+ext)130221.rar
- 网上商城系统(JSP+MYSQL)130220.rar
- 网上商城系统(JSP+MYSQL).rar
- 网上购物系统(JavaBean+Servlet+jsp)130223.rar
- 网上书城系统(Struts+Hibernate+Mysql)130222.rar