Kingfisher Documentation

Protocol KFImage​Protocol

@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public protocol KFImageProtocol: View, KFOptionSetter  
%247 KFImageProtocol KFImageProtocol KFOptionSetter KFOptionSetter KFImageProtocol->KFOptionSetter View View KFImageProtocol->View KFAnimatedImage KFAnimatedImage KFAnimatedImage->KFImageProtocol KFImage KFImage KFImage->KFImageProtocol

Conforms To

KFOptionSetter
View

Types Conforming to KFImage​Protocol

KFAnimatedImage
KFImage

Default Implementations

source(_:​)

public static func source(
        _ source: Source?
    ) -> Self

Creates a KFImage for a given Source.

Parameters

source Source?

The Source object defines data information from network or a data provider.

Returns

A KFImage for future configuration or embedding to a SwiftUI.View.

resource(_:​)

public static func resource(
        _ resource: Resource?
    ) -> Self

Creates a KFImage for a given Resource.

Parameters

source

The Resource object defines data information like key or URL.

Returns

A KFImage for future configuration or embedding to a SwiftUI.View.

url(_:​cache​Key:​)

public static func url(
        _ url: URL?, cacheKey: String? = nil
    ) -> Self

Creates a KFImage for a given URL.

Parameters

url URL?

The URL where the image should be downloaded.

cache​Key String?

The key used to store the downloaded image in cache. If nil, the absoluteString of url is used as the cache key.

Returns

A KFImage for future configuration or embedding to a SwiftUI.View.

data​Provider(_:​)

public static func dataProvider(
        _ provider: ImageDataProvider?
    ) -> Self

Creates a KFImage for a given ImageDataProvider.

Parameters

provider Image​Data​Provider?

The ImageDataProvider object contains information about the data.

Returns

A KFImage for future configuration or embedding to a SwiftUI.View.

data(_:​cache​Key:​)

public static func data(
        _ data: Data?, cacheKey: String
    ) -> Self

Creates a builder for some given raw data and a cache key.

Parameters

data Data?

The data object from which the image should be created.

cache​Key String

The key used to store the downloaded image in cache.

Returns

A KFImage for future configuration or embedding to a SwiftUI.View.

placeholder(_:​)

public func placeholder<P: View>(@ViewBuilder _ content: @escaping (Progress) -> P) -> Self  

Sets a placeholder View which shows when loading the image, with a progress parameter as input.

Parameters

content @escaping (Progress) -> P

A view that describes the placeholder.

Returns

A KFImage view that contains content as its placeholder.

placeholder(_:​)

public func placeholder<P: View>(@ViewBuilder _ content: @escaping () -> P) -> Self  

Sets a placeholder View which shows when loading the image.

Parameters

content @escaping () -> P

A view that describes the placeholder.

Returns

A KFImage view that contains content as its placeholder.

cancel​OnDisappear(_:​)

public func cancelOnDisappear(_ flag: Bool) -> Self  

Sets cancelling the download task bound to self when the view disappearing.

Parameters

flag Bool

Whether cancel the task or not.

Returns

A KFImage view that cancels downloading task when disappears.

fade(duration:​)

public func fade(duration: TimeInterval) -> Self  

Sets a fade transition for the image task.

Kingfisher will use the fade transition to animate the image in if it is downloaded from web. The transition will not happen when the image is retrieved from either memory or disk cache by default. If you need to do the transition even when the image being retrieved from cache, also call forceRefresh() on the returned KFImage.

Parameters

duration Time​Interval

The duration of the fade transition.

Returns

A KFImage with changes applied.

body

public var body: some View  

init(source:​)

public init(source: Source?)  

Creates a Kingfisher compatible image view to load image from the given Source.

Parameters

source Source?

The image Source defining where to load the target image.

init(_:​)

public init(_ url: URL?)  

Creates a Kingfisher compatible image view to load image from the given URL.

Parameters

source

The image Source defining where to load the target image.

configure(_:​)

public func configure(_ block: @escaping (HoldingView) -> HoldingView) -> Self  

Configures current image with a block. This block will be lazily applied when creating the final Image.

Parameters

block @escaping (Holding​View) -> Holding​View

The block applies to loaded image.

Returns

A KFImage view that configures internal Image with block.

options

public var options: KingfisherParsedOptionsInfo  

on​Failure​Delegate

public var onFailureDelegate: Delegate<KingfisherError, Void>  

on​Success​Delegate

public var onSuccessDelegate: Delegate<RetrieveImageResult, Void>  

on​Progress​Delegate

public var onProgressDelegate: Delegate<(Int64, Int64), Void>  

delegate​Observer

public var delegateObserver: AnyObject  

Requirements

Holding​View

associatedtype HoldingView: KFImageHoldingView

context

var context: KFImage.Context<HoldingView>  

init(context:​)

init(context: KFImage.Context<HoldingView>)