Reputation: 11
import UIKit
class UserProfileController : UICollectionViewController, UICollectionViewDelegateFlowLayout{
override func viewDidLoad() {
super.viewDidLoad()
collectionView?.backgroundColor = .white
//NEED TO UPDATE: GET USERNAME TO AND SET NAVTITLE
fetchUser()
//UPDATE ALL USER PAGE INFO IN
collectionView?.register(UICollectionViewCell.self, forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, withReuseIdentifier: "headerId")
}
fileprivate func fetchUser(){
//Assumed loged in get user ID
//guard let uid = currentUser?.uid else {return}
//NEED TO UPDATE: GET USERNAME FROM USER ID HASH
let username = "User Profile"
navigationItem.title = username
}
override func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "headerId", for: indexPath)
header.backgroundColor = .green
return header
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
return CGSize(width: view.frame.width, height: 200)
}
}
I just programmatically set an header, register it also gave it size by using referencesizeforheader. But it will not display on the screen. I also use this controller on the tab bar. In Scene delegate ı made the rootController of this tabbar controller. In the code side ı think there is no problem but ı can't see any difference. Could you help me please ?
Upvotes: 1
Views: 29