Skip to content

Instantly share code, notes, and snippets.

@KrauserHuang
Created December 29, 2020 03:18
Show Gist options
  • Save KrauserHuang/c2ee5976d6e1a9c620f48e7fd4e6852b to your computer and use it in GitHub Desktop.
Save KrauserHuang/c2ee5976d6e1a9c620f48e7fd4e6852b to your computer and use it in GitHub Desktop.
//個人介紹、貼文數、被追蹤數、追蹤數
override func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
let reusableCell = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: PropertyKeys.header, for: indexPath) as! ProfileCollectionReusableView
reusableCell.profileImageView.layer.cornerRadius = reusableCell.profileImageView.frame.height / 2
if igdata != nil {
reusableCell.profileName.text = igdata.graphql.user.full_name
// reusableCell.postsNumLabel.text = "\(igdata.graphql.user.edge_owner_to_timeline_media.count)"
reusableCell.postsNumLabel.text = postsNumConvert(igdata.graphql.user.edge_owner_to_timeline_media.count)
// reusableCell.followersNumLabel.text = "\(igdata.graphql.user.edge_followed_by.count)"
reusableCell.followersNumLabel.text = followerNumConvert(igdata.graphql.user.edge_followed_by.count)
// reusableCell.followingNumLabel.text = "\(igdata.graphql.user.edge_follow.count)"
reusableCell.followingNumLabel.text = followingNumConvert(igdata.graphql.user.edge_follow.count)
reusableCell.biographyLabel.text = igdata.graphql.user.biography
//抓圖的部分都移至main thread
URLSession.shared.dataTask(with: igdata.graphql.user.profile_pic_url_hd) { (data, response, error) in
if let data = data {
DispatchQueue.main.async {
reusableCell.profileImageView.image = UIImage(data: data)
}
}
}.resume()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment