AYImageKit
AYImageKit is a Swift Library for Async Image Downloading.
Features
- Async Image Downloading.
- Can Show Text Initials.
- Can have Custom Styles.
- Can Preview Image In Separate Screen with Animation.
- Can Show ActivityIndicator while image loading.
- Can Add Placeholder Image.
- Can Cache Image In Memory.
- Can Cache Image In Disk.
- Make Round Image.
- Image Sharing Option.
- Work Well in Table View and Collection View cell.
ScreenShot
Installation
AYImageKit is only available via CocoaPods:
pod 'AYImageKit'
Usage
Via Storyboard.
- Add View in controller.
- Assign AYImageView Class to View.
In View Controller Class.
- If you only want to show Image.
import AYImageKit
class ViewController: UIViewController {
@IBOutlet weak var imageView: AYImageView!
override func viewDidLoad() {
super.viewDidLoad()
imageView.currentViewController = self
imageView.setImageFromUrl(url: "your url link here")
}
}
- If you want to show name's Initials in case of url broken or image is not available then.
imageView.currentViewController = self
imageView.text = "Adnan Yousaf"
imageView.setImageFromUrl(url: "your url link here")
- If you want to show placeholder Image in case of url broken or image is not available then.
imageView.currentViewController = self
imageView.placeHolderImage = UIImage(named: "")
imageView.setImageFromUrl(url: "your url link here")
- If you want to get image then use completion handler.
imageView.setImageFromUrl(url: "your url link here") { result in
switch result {
case .success(let image):
self.imageView.setImage(image)
case .error(let error):
print(error.localizedDescription)
}
}
- If you want to set Image directly.
imageView.currentViewController = self
imageView.setImage(UIImage(named: ""))
- If you want to set name's initials only.
imageView.showInitialsName("Adnan Yousaf")
- Cache Properties
imageView.cacheInDisk = false
imageView.cacheInMemory = false
- Styling
imageView.updateStyle(with: Style(font: UIFont.systemFont(ofSize: 34),
textColor: UIColor.white,
background: UIColor.black,
borderColor: UIColor.black))
- Further Customization
imageView.isCircular = true
/// if `true` AYImageView will be in circular shape. Default is `false`
imageView.isAllowToOpenImage = true
// if `true` AYImageView will be interactive and can open ImageViewer. Default is `true`
imageView.isSharingEnabled = true
// if `true` ImageViewerViewController will show a button to share image. Default is `true`
imageView.isShowActivityIndicator = true
//if `true` AYImageViewer will show activity indicator during downloading image. Default is `true`
imageView.imageContentMode = .scaleAspectFill
// set Image content mode of imageView. Default is `scaleAspectFit`
imageView.isforceRemoteFetchingEnabled = false
//if `true` ImageDownloader will download image whether image is present in cache or not. Default is `false`
For more Detail See Example project.
Contributing
- If you want to contribute, submit a pull request.
- If you found a bug, have suggestions or need help, please, open an issue.
- If you need help, write me: [email protected]
License
AYImageKit is released under the MIT license.