UICollectionView가 있는데 완벽하게 작동합니다. 나는 행 0 제외한 모든 행에 잠금 이미지를 추가했습니다. ViewController로드 될 때 잘 작동하지만 가로로 스크롤 할 때 행 0 잠금 이미지를 표시합니다. 내가 뭘 잘못하고있다? advace에 감사드립니다. 여기 스크롤 할 때 UICollectionView의 행 0에서 이미지 잠금을 숨기는 방법 swift3
내 코드입니다 : -var imageView1 = UIImageView()
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "CollectionViewCell", for: indexPath) as! CollectionViewCell
cell.label.text = tittle[indexPath.row]
cell.imageView.image = UIImage(named : image[indexPath.row])
imageView1 = UIImageView(frame:CGRect(x :cell.frame.size.width/2 - 30 ,y : 40, width : 30, height : 30));
imageView1.image = UIImage(named: "lock.png")
imageView1.image = imageView1.image!.withRenderingMode(.alwaysTemplate)
imageView1.tintColor = UIColor.white
if (indexPath.row == 0) {
imageView1.isHidden = true
imageView1.removeFromSuperview()
} else {
cell.imageView.addSubview(imageView1)
if (RemoteModel.sharedInstanceRemoteModel.purchased){
imageView1.isHidden = true
} else {
imageView1.isHidden = false
}
}
return cell
}
코드를 보여 주실 수 있습니까? –
코드 버디가 추가되었습니다. –
UIImageView에서 Subview UIImageView를 추가하는 이유는 무엇입니까? –