Jinsujin / translate-documents

iOS 연관 문서 번역
0 stars 0 forks source link

ScrollView #7

Closed Jinsujin closed 1 year ago

Jinsujin commented 1 year ago

문서링크

@MainActor class UIScrollView : UIView

사용하기

스크롤 가로 이동하기

scrollView.setContentOffset(CGPoint(x: 414, y: 0), animated: false)        

스크롤 뷰 + 스택뷰로 레이아웃 잡기

view.addSubview(scrollView)
scrollView.addSubview(stackView)

NSLayoutConstraint.activate([
    scrollView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
    scrollView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
    scrollView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
    scrollView.heightAnchor.constraint(equalToConstant: 200)
])

NSLayoutConstraint.activate([
    stackView.topAnchor.constraint(equalTo: scrollView.contentLayoutGuide.topAnchor),
    stackView.bottomAnchor.constraint(equalTo: scrollView.contentLayoutGuide.bottomAnchor),
    stackView.leadingAnchor.constraint(equalTo: scrollView.contentLayoutGuide.leadingAnchor),
    stackView.trailingAnchor.constraint(equalTo: scrollView.contentLayoutGuide.trailingAnchor)
])