CollectionView에서 셀 고르게 표시 - 셀 위에 배율로 표시 버튼
7793 단어 AutoLayoutXcodeSwiftiOS
Result
세 열에 셀 보이기

4:07AM에 어울리는 건 귀여움!🌙
인코딩
https://github.com/keisei1092/celltest
Init




이제 준비됐습니다.
CollectionViewCell 균일하게 배치
코드를 쓰다.
import UIKit
class ViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
return collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as UICollectionViewCell
}
func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
return 1
}
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 20;
}
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
return CGSizeMake(self.view.frame.size.width / 3 - 2, self.view.frame.size.width / 3 - 2)
}
}
오른쪽 아래에 단추 보이기




Reference
이 문제에 관하여(CollectionView에서 셀 고르게 표시 - 셀 위에 배율로 표시 버튼), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/keisei_1092/items/6f4ffd63e191f98de017텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)