【Swift】storyboard를 이용하지 않는 템플릿(UICollectionView, UICollectionViewCell)
개요
PureLayout의 샘플(UICollectionView, UICollectionViewCell) 제3탄입니다.
 Yahoo 경매 검색 API 결과가 CollectionView에 표시됩니다.
다음에는 UITabBar
 목적
 storyboard를 사용하지 않는 최소한의 템플릿(Swift)을 참조하십시오.
 장점 (PureLayout vs Storyboard)
 [Swift] storyboard를 사용하지 않는 템플릿(기본 View)을 참조하십시오.
 대상View
storyboard를 사용하지 않는 최소한의 템플릿(Swift)을 참조하십시오.
장점 (PureLayout vs Storyboard)
 [Swift] storyboard를 사용하지 않는 템플릿(기본 View)을 참조하십시오.
 대상View
결과
 
 github
AutoLayout 설정
 CollectionView(&SearchBar)
    private func addConstraints() {
        searchBar.autoPinToTopLayoutGuideOfViewController(self, withInset: 0)
        searchBar.autoPinEdgeToSuperviewEdge(.Left)
        searchBar.autoPinEdgeToSuperviewEdge(.Right)
        collectionView.autoPinEdge(.Top, toEdge: .Bottom, ofView: searchBar)
        collectionView.autoPinEdgeToSuperviewEdge(.Left)
        collectionView.autoPinEdgeToSuperviewEdge(.Right)
        collectionView.autoPinEdgeToSuperviewEdge(.Bottom)
    }
 CollectionViewCell의 각 View
    private func addConstraints() {
        itemImageView.autoPinEdgeToSuperviewEdge(.Top, withInset: 2)
        itemImageView.autoPinEdgeToSuperviewEdge(.Left, withInset: 2)
        itemImageView.autoPinEdgeToSuperviewEdge(.Right, withInset: 2)
        titleLabel.autoPinEdge(.Top, toEdge: .Bottom, ofView: itemImageView, withOffset: 3.0)
        titleLabel.autoPinEdgeToSuperviewEdge(.Left, withInset: 2)
        titleLabel.autoPinEdgeToSuperviewEdge(.Right, withInset: 2)
        priceLabel.autoPinEdge(.Top, toEdge: .Bottom, ofView: titleLabel, withOffset: 3.0)
        priceLabel.autoPinEdgeToSuperviewEdge(.Left, withInset: 2)
        priceLabel.autoPinEdgeToSuperviewEdge(.Right, withInset: 2)
        endTimeLabel.autoPinEdge(.Top, toEdge: .Bottom, ofView: priceLabel, withOffset: 3.0)
        endTimeLabel.autoPinEdgeToSuperviewEdge(.Left, withInset: 2)
        endTimeLabel.autoPinEdgeToSuperviewEdge(.Bottom, withInset: 5)
        bidLabel.autoPinEdge(.Top, toEdge: .Bottom, ofView: priceLabel, withOffset: 3.0)
        bidLabel.autoPinEdge(.Left, toEdge: .Right, ofView: endTimeLabel, withOffset: 10.0)
        bidLabel.autoPinEdgeToSuperviewEdge(.Bottom, withInset: 5)
    }
                
                    
        
    
    
    
    
    
                
                
                
                
                    
                        
                            
                            
                            Reference
                            
                            이 문제에 관하여(【Swift】storyboard를 이용하지 않는 템플릿(UICollectionView, UICollectionViewCell)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
                                
                                https://qiita.com/menomoto/items/35cb3a8c7ddd819bf7c7
                            
                            
                            
                                텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                            
                            
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                            
                            
                        
                    
                
                
                
            
    private func addConstraints() {
        searchBar.autoPinToTopLayoutGuideOfViewController(self, withInset: 0)
        searchBar.autoPinEdgeToSuperviewEdge(.Left)
        searchBar.autoPinEdgeToSuperviewEdge(.Right)
        collectionView.autoPinEdge(.Top, toEdge: .Bottom, ofView: searchBar)
        collectionView.autoPinEdgeToSuperviewEdge(.Left)
        collectionView.autoPinEdgeToSuperviewEdge(.Right)
        collectionView.autoPinEdgeToSuperviewEdge(.Bottom)
    }
    private func addConstraints() {
        itemImageView.autoPinEdgeToSuperviewEdge(.Top, withInset: 2)
        itemImageView.autoPinEdgeToSuperviewEdge(.Left, withInset: 2)
        itemImageView.autoPinEdgeToSuperviewEdge(.Right, withInset: 2)
        titleLabel.autoPinEdge(.Top, toEdge: .Bottom, ofView: itemImageView, withOffset: 3.0)
        titleLabel.autoPinEdgeToSuperviewEdge(.Left, withInset: 2)
        titleLabel.autoPinEdgeToSuperviewEdge(.Right, withInset: 2)
        priceLabel.autoPinEdge(.Top, toEdge: .Bottom, ofView: titleLabel, withOffset: 3.0)
        priceLabel.autoPinEdgeToSuperviewEdge(.Left, withInset: 2)
        priceLabel.autoPinEdgeToSuperviewEdge(.Right, withInset: 2)
        endTimeLabel.autoPinEdge(.Top, toEdge: .Bottom, ofView: priceLabel, withOffset: 3.0)
        endTimeLabel.autoPinEdgeToSuperviewEdge(.Left, withInset: 2)
        endTimeLabel.autoPinEdgeToSuperviewEdge(.Bottom, withInset: 5)
        bidLabel.autoPinEdge(.Top, toEdge: .Bottom, ofView: priceLabel, withOffset: 3.0)
        bidLabel.autoPinEdge(.Left, toEdge: .Right, ofView: endTimeLabel, withOffset: 10.0)
        bidLabel.autoPinEdgeToSuperviewEdge(.Bottom, withInset: 5)
    }
Reference
이 문제에 관하여(【Swift】storyboard를 이용하지 않는 템플릿(UICollectionView, UICollectionViewCell)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/menomoto/items/35cb3a8c7ddd819bf7c7텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)