SwiftUI實(shí)戰(zhàn)系列
- SwiftUI實(shí)戰(zhàn)-使用ViewModifier自定義微信TabBar底部導(dǎo)航和NavigationView
- SwiftUI實(shí)戰(zhàn)-NavigationLink圖片和文字顯示藍(lán)色或者圖片無(wú)顯示
- SwiftUI實(shí)戰(zhàn)-去除List分割線
- SwiftUI實(shí)戰(zhàn)-自定義彈窗
- SwiftUI實(shí)戰(zhàn)-自定義加載指示器HUD
- SwiftUI實(shí)戰(zhàn)-廣告頁(yè)饭庞、歡迎頁(yè)
- SwiftUI實(shí)戰(zhàn)-NavigationView + TabView基本框架搭建
- SwiftUI實(shí)戰(zhàn)-Pager分頁(yè)查看器
- SwiftUI實(shí)戰(zhàn)-隱私政策和用戶(hù)協(xié)議彈窗
- SwiftUI實(shí)戰(zhàn)-多圖橄登、大圖圖片瀏覽
- SwiftUI實(shí)戰(zhàn)-下拉菜單
- SwiftUI實(shí)戰(zhàn)-系統(tǒng)NavigationView自定義titleView
- SwiftUI實(shí)戰(zhàn)-WKWebView的使用
- SwiftUI實(shí)戰(zhàn)-自定義轉(zhuǎn)圈指示器
- SwiftUI實(shí)戰(zhàn)-自定義TextField搭建登錄頁(yè)面UI
- SwiftUI實(shí)戰(zhàn)-自定義底部彈窗
- SwiftUI實(shí)戰(zhàn)-顯示星級(jí)評(píng)分
- SwiftUI實(shí)戰(zhàn)-類(lèi)似新聞?lì)^條輪播滾動(dòng)
- SwiftUI實(shí)戰(zhàn)-仿用戶(hù)協(xié)議確認(rèn)頁(yè)面支持點(diǎn)擊文字顯示協(xié)議
- SwiftUI實(shí)戰(zhàn)-新特性、新版本介紹
- SwiftUI實(shí)戰(zhàn)-多圖選擇败富、圖片選擇器
- SwiftUI實(shí)戰(zhàn)-輪播圖
- SwiftUI實(shí)戰(zhàn)-網(wǎng)絡(luò)請(qǐng)求工具封裝
- SwiftUI實(shí)戰(zhàn)-多級(jí)聯(lián)動(dòng)地址選擇
- SwiftUI實(shí)戰(zhàn)-使用UIActivityIndicatorView
- SwiftUI實(shí)戰(zhàn)-Expanded可伸縮的分組列表List
- SwiftUI實(shí)戰(zhàn)-滾動(dòng)列表內(nèi)容返回頂部悔醋、底部、指定位置
- SwiftUI實(shí)戰(zhàn)-List列表內(nèi)容動(dòng)態(tài)改變更新
- SwiftUI-繪制氣泡圖
- SwiftUI-仿微信加號(hào)Popover氣泡彈窗
- SwiftUI實(shí)戰(zhàn)-單邊圓角單個(gè)圓角
本章內(nèi)容
無(wú)限輪播圖
相關(guān)源碼:
ContentView.swift
import SwiftUI
struct ContentView: View {
@State var imagesName = ["12345", "67891"]
@State var images = ["12345", "67891"]
@State var currentIndex: Int = 0
var body: some View {
VStack {
ZStack(alignment: .bottom) {
CustomLoopView.init(urls: images, currentIndex: $currentIndex)
HStack(alignment: .center, spacing: 6) {
ForEach(0..<imagesName.count, id:\.self ) { index in
let isCurrentIndex = index == currentIndex
Color(isCurrentIndex ? .systemBlue : .white).cornerRadius(2).frame(width: isCurrentIndex ? 10 : 4, height: 4)
}
}
.frame(height: 20)
}
Spacer()
}.onAppear {
images = [imagesName.last!] + images + [imagesName.first!]
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
CustomLoopView.swift