40줄 UIScrollView의 간단한 튜토리얼 화면 샘플만 사용
 프로그램이 처음 시작될 때 가로로 점프하는 보행형 튜토리얼 화면을 만드는 방법이다.
UIPage View Controller도 할 수 있지만, 나는 UIScrollView가 비교적 간단하고 간단하면 충분하다고 생각한다.
다양한 도서관도 있지만 만드는 게 편할 것 같아요.
다음 코드가 전부입니다.40줄 정도면 완성됩니다.
import UIKit
class ViewController: UIViewController, UIScrollViewDelegate {
    var scrollView: UIScrollView!
    var pageControll: UIPageControl!
    let pageNum = 4
    let pageColors:[Int:UIColor] = [1:UIColor.redColor(),2:UIColor.yellowColor(),3:UIColor.blueColor(),4:UIColor.greenColor()]
    override func viewDidLoad() {
        super.viewDidLoad()
        self.scrollView = UIScrollView(frame: self.view.bounds)
        self.scrollView.contentSize = CGSizeMake(self.view.bounds.width * CGFloat(pageNum), self.view.bounds.height)
        self.scrollView.pagingEnabled = true
        self.scrollView.showsHorizontalScrollIndicator = false
        self.scrollView.delegate = self;
        self.view.addSubview(self.scrollView)
        self.pageControll = UIPageControl(frame: CGRectMake(0, self.view.bounds.height-50, self.view.bounds.width, 50))
        self.pageControll.numberOfPages = pageNum
        self.pageControll.currentPage = 0
        self.view.addSubview(self.pageControll)
        for p in 1...pageNum {
            var v = UIView(frame: CGRectMake(self.view.bounds.width * CGFloat(p-1), 0, self.view.bounds.width, self.view.bounds.height))
            v.backgroundColor = self.pageColors[p]
            self.scrollView.addSubview(v)
        }
    }
    func scrollViewDidScroll(scrollView: UIScrollView) {
        var pageProgress = Double(scrollView.contentOffset.x / scrollView.bounds.width)
        self.pageControll.currentPage = Int(round(pageProgress))
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
}
                Reference
이 문제에 관하여(40줄 UIScrollView의 간단한 튜토리얼 화면 샘플만 사용), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/osamu1203/items/a1a361f9ff00e93258e2텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)