티스토리 뷰
728x90
반응형

/// 커스텀 페이지 컨트롤 애니메이션 Custom PageControl + Animation
struct PageControl: View {
var numberOfPages: Int
@Binding var currentPage: Int
var body: some View {
HStack(spacing: 8) {
ForEach(0..<numberOfPages, id: \.self) { pagingIndex in
let isCurrentPage = currentPage == pagingIndex
let height = 8.0
let width = isCurrentPage ? height * 2 : height
Capsule()
.fill(isCurrentPage ? .blue : .gray.opacity(0.5))
.frame(width: width, height: height)
}
}
.animation(.linear, value: currentPage)
}
}
#Preview {
PageControl(numberOfPages: 3, currentPage: .constant(0))
}
struct ContentView: View {
let array: [Color] = [.red, .green, .blue]
@State var selection = 0
var body: some View {
VStack {
TabView(selection: $selection) {
ForEach(array.indices, id: \.self) {
array[$0]
.tag($0)
}
}
.tabViewStyle(.page(indexDisplayMode: .never))
.frame(width: 300, height: 300)
PageControl(numberOfPages: array.count, currentPage: $selection)
}
}
}
iOS
Swift
Xcode
PageControl
UIPageControl
TabView
tabViewStyle
indexDisplayMode
페이지컨트롤
인디케이터
indicator
728x90
반응형
'iOS SwiftUI' 카테고리의 다른 글
iOS SwiftUI Custom Slider 커스텀 슬라이더 (제어센터 UI) (0) | 2024.08.01 |
---|---|
[TIL] iOS SwiftUI 글자수, 단어수, 줄수 세기 + 복사, 공유, 툴바, 키보드 닫기 등 (0) | 2024.07.01 |
iOS SwiftUI 드래그 앤 드롭 Drag And Drop (DND) (0) | 2024.04.01 |
iOS SwiftUI FlowLayout 컨텐츠 크기 만큼 아래로 배치 되는 레이아웃 (2) | 2024.02.01 |
iOS SwiftUI TabView 의 tabItem 누를 때 탭 전환 대신, 네비게이션 이동 (0) | 2024.01.01 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- Xcode
- 아이오에스
- swiftUI
- presentationcompactadaptation
- 엑스코드
- TabBar
- 테이블뷰
- 다국어
- SKProductsRequestDelegate
- SWIFT
- 프로그레스
- AppStore
- Reject
- TabView
- Authorization
- localizing
- permission
- SKPayment
- 인디케이터
- ios
- Language
- picker
- 스위프트
- custom segment
- 현지화
- indicator
- 심사
- 리젝
- localizable
- 로컬라이징
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
글 보관함