• UIScrollView Infinite Paging

    원하는 영역에 ScrollView와 StackView를 구현한다. StackView에 뷰를 3개 넣는다. (preView, currentView, nextView) 초기엔 currentView를 보게끔 ‘self.scrollView.setContentOffset’를 설정해준다. self.scrollView.setContentOffset(CGPoint(x: width, y: 0), animated: false) 데이터가 총 max개 있다고 가정할때 현재 StackView에 있는 데이터는 { preView: max-1, currentView: 0 (현재 보고있는 곳) , nextView: 1 } 이렇게 된다. 다음 화면으로 넘기게 되면...


  • ScrollView Paging Size Tip

    스크롤뷰에서 scrollview.isPagingEnabled = true 를 하게 되면 페이징 기능을 이용할 수 있다. 이 페이징의 사이즈는 스크롤 뷰의 사이즈와 동일하다. 이전, 이후의 뷰가 조금씩 보여지는 디자인일 경우에는 페이징 하게되면 전체 페이지가 넘어가기 때문에 조금 수정을 해야한다. 찾아본결과 여러가지 방법이 있었지만 그중 가장 괜찮은 방법은 scrollview.clipsToBounds = false 를 주고, scrollview.contentInset =...


  • 스토리보드 없이 시작하기

    AppDelegate.swift 의 didFinishLaunchingWithOptions 에 처음 보여줄 VC를 연결한다. self.window = UIWindow(frame: UIScreen.main.bounds) self.window?.rootViewController = MainVC() self.window?.makeKeyAndVisible() App -> General -> Deployment Info -> Main Interface 에 main을 지워준다 Main.storyboard를 삭제한다. 추가 (네비게이션을 추가하고 싶을 때) self.window = UIWindow(frame: UIScreen.main.bounds) let rootVC = MainVC() let naviVC = UINavigationController(rootViewController: rootVC) self.window?.rootViewController =...


  • Infinite CollectionView

    CollectionView 를 이용한 무한 페이징 코드입니다. let arrays = ["a", "b", "c', "d"] 갯수는 arrays + 4 개를 할당합니다. func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return arrays.count + 4 } 사이즈는 원하는 대로 func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {...


  • 앱을 재시작하기

    앱을 재 시작 하고 싶을 땐 UIApplication.shared.keyWindow?.rootViewController = MainVC() 를 하면 처음 화면으로 돌아간다.