NetworkImage - Tai-Kimura/SwiftJsonUI GitHub Wiki

NetworkImage

class: NetworkImageView inherites: [SJUIImageView](/Tai-Kimura/SwiftJsonUI/wiki/Image) child classes: [CircleImageView](/Tai-Kimura/SwiftJsonUI/wiki/CircleImage)

Platform Support

  • UIKit: Full support (All attributes available)
  • SwiftUI: Full support (Maps to AsyncImage)

Attributes for NetworkImage

attribute name UIKit SwiftUI type in json details remarks
src string URL string for remote image
defaultImage string Default image name to display initially
errorImage string Image to show when download fails
loadingImage string Image to show while downloading
contentMode string Content mode: AspectFill (default), AspectFit, Center
cachePolicy string Cache policy for downloaded images UIKit only
timeout float Download timeout in seconds UIKit only
All Image attributes - Inherits all attributes from Image See Image

Functions for NetworkImage

open func setImageResource(_ image: UIImage?)

Use this method to set local image.Downloader will be cancel when this method is called.

open func setImageURL(string: String!)
open func setImageURL(url: URL)

Use this method to set remote image.Downloader will start downloading when this method is called.Once image is downloaded, it will be sotred in disc until stored file size achieve to the limit.

@discardableResult open class func deleteCacheForPath(url: URL!) -> Bool

Use this method to clear image cache.

public class func createFromJSON(attr: JSON, target: Any, views: inout [String: UIView]) -> NetworkImageView

This method will be called when it's created from json file. Override This method when you create classes inherite NetworkImageView class.