ios开发:kingfisher安装和使用

一,安装:

官方地址:

https://gitcode.com/GitHub_Trending/ki/Kingfisher

二,代码:

import Kingfisher
import SwiftUI

struct DetailView: View {
    let id: Int // 接收传递过来的 id

    var body: some View {
        VStack(spacing: 20) {

            
            let img_url = "https://raw.gitcode.com/GitHub_Trending/ki/Kingfisher/raw/fa3609d1975791c0a6e6f75a56dc20a957967769/images/kingfisher-2.jpg"
            KFImage(URL(string: img_url))
                   .fade(duration: 0.33)
                   .placeholder { ProgressView() }
                   .resizable()
                   .scaledToFit()
                   .frame(width: 200, height: 200)

        }
        .navigationTitle("详情")
        // SwiftUI 默认在导航跳转时提供“从右向左”的滑动动画
    }
}

三,测试效果

image

 

posted @ 2026-04-04 10:37  刘宏缔的架构森林  阅读(2)  评论(0)    收藏  举报