Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
Tags
- 페이지이동함수
- featured-sliced-design
- react fsd
- react modal
- @published 프로퍼티 래퍼
- zustand란
- react hook
- BFS
- @environmentobject 프로퍼티 래퍼
- 동기 함수 내에서 비동기 함수 호출
- react상태관리라이브러리
- 블로그업로드확인
- 리렌더링최적화
- 가로모드끄기
- C++
- modal 관리
- navigationBar 숨기기
- 반응형 css
- 컴퓨터네트워크
- 페이지전환
- 비동기함수
- LazyVGrid
- 리액트최적화
- GridItem
- CSS
- LazyHGrid
- zustand
- react-router-dom
- 세로모드끄기
- @observedobject 프로퍼티 래퍼
Archives
- Today
- Total
leebaek
[SwiftUI] ScrollView | 스크롤뷰 본문
■ScrollView
■ScrollView
: 스크롤 가능한 뷰
struct ScrollView<Content> where Content : View
> 초기값
- 수직축으로 설정됨
- 막대기 바가 보이게 설정됨
init(Axis.Set, showsIndicators: Bool, content: () -> Content)
init(
_ axes: Axis.Set = .vertical, // 수직축
showsIndicators: Bool = true, // 막대기 보이게
@ViewBuilder content: () -> Content
)
스크롤 위치 제어 | Axis.Set
- 가로, 세로 방향 설정 가능 ( 확대, 축소 기능은 없음 )
// [.vertical]
// [.horizontal]
// [.vertical, .horizontal]
ScrollView([.vertical])
ScrollView([.horizontal])
ScrollView([.vertical,.horizontal])
> 처음 스크롤 되는 위치 설정
.defaultScrollAnchor()
.center // 중간에서 시작
.bottom // 수직축 아래에서 시작
예시 )
ScrollView([.horizontal, .vertical]) {
// initially centered content
}
.defaultScrollAnchor(.center)
스크롤 바 제어 | showIndicators
- 스크롤 바 보이게, 안 보이게 설정 가능
// showsIndicators: <Bool>
// showsIndicators: true
// showsIndicators: false
ScrollView(showsIndicators: true)
ScrollView(showsIndicators: false)
ex. 수평 방향 스크롤 뷰 / 중간부터 시작 / 스크롤 바 제거
import SwiftUI
struct ContentView: View {
var body: some View {
ScrollView([.horizontal],showsIndicators: false){
HStack {
ForEach(0..<100) {
Text("Row \($0)")
}
}
}
.defaultScrollAnchor(.center)
}
}
#Preview {
ContentView()
}
'개발 > Swift' 카테고리의 다른 글
[Swift] 데이터 타입 | 스위프트 변수, 상수, 타입애너테이션 (1) | 2023.12.27 |
---|---|
[SwiftUI] NavigationView & NavigationLink (기본) (0) | 2023.11.23 |
[SwiftUI] ScrollViewReader & ScrollViewProxy | 스크롤뷰 리더, 프록시 (0) | 2023.11.08 |
[SwiftUI] ScrollTo (0) | 2023.11.08 |
[SwiftUI] view life cycle | view 생명주기 (0) | 2023.10.31 |