3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Kingfisher の通信を Basic 認証に対応させる

Last updated at Posted at 2017-02-19

ImageDownloadRequestModifier (AnyModifier) を利用して URLRequest に変更を加えると良い。

var options: KingfisherOptionsInfo = [
		.scaleFactor(UIScreen.main.scale),
		.transition(ImageTransition.fade(0.35)),
		]

let encodedAuth = 

let modifier: AnyModifier = AnyModifier.init(modify: { (req: URLRequest) -> URLRequest? in
	var r = req
	r.setValue("Basic \(encodedAuth)", forHTTPHeaderField: "Authorization")
	return r
})
options.append(.requestModifier(modifier))

imageView.kf.setImage(with: URL,
		      placeholder: placeholder,
		      options: options,
		      progressBlock: nil,
		      completionHandler: nil)
3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?