Contents 非表示
実装
Kingfisherのインストール
pod 'Kingfisher', '~> 7.0'
Storyboard
コード
import UIKit
import Kingfisher
class ViewController: UIViewController {
// MARK: - Properties
@IBOutlet private weak var titleLabel: UILabel!
@IBOutlet private weak var imageView: UIImageView!
// MARK: - View Life Cycle
override func viewDidLoad() {
super.viewDidLoad()
setupView()
}
private func setupView() {
let url = URL(string: "https://stat.ameba.jp/user_images/20140409/00/kamenrider-takarin/62/f0/j/o0350023312902837578.jpg?caw=800")
imageView.kf.setImage(with: url)
}
@IBAction func changeImagesAction(_ sender: Any) {
let url = URL(string: "https://pbs.twimg.com/profile_images/646303588617089024/ccBnONF4_400x400.jpg")
imageView.kf.setImage(with: url)
titleLabel.text = "オレァ、クサムヲムッコロス!"
}
}