0

UICollectionViewセルにUIImageViewがあり、画面サイズに基づいてプログラムで調整しています。セルは2つの列を作成し、コレクションを表示するときに画像が画面の中央付近に表示されるようにします。uicollectionviewセルでイメージビューの位置を調整するにはどうすればよいですか?

override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { 
    let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as! ProfileCollectionViewCell 

    cell.myLabel?.text = fetchName() 
    cell.myImage?.image = fetchImage() 

    if(indexPath.item % 2 == 0) { 
     cell.myImage?.frame.origin.x = (cell.frame.size.width/3) * 2 
     cell.myImage?.frame.origin.y = cell.frame.size.height/2 
    } 
    else { 
     cell.myImage?.frame.origin.x = (cell.frame.size.width/3) 
     cell.myImage?.frame.origin.y = cell.frame.size.height/2 
    } 

    cell.myImage?.layer.cornerRadius = (cell.myImage?.frame.size.width)!/2 
    cell.myImage?.layer.masksToBounds = true 
    return cell 
} 

これは実際にはイメージビューを全く移動していないようです。私もcell.myImage?centerを調整しようとしましたが、これには何の効果もありませんでした。では、このセルの周りにイメージを移動するにはどうすればいいですか?

+0

役に立てば幸いあなたのためにこれは、あなたが

を達成したい何をすべきかの場所であるあなたのProfileCollectionViewCelllayoutSubviews方法でimageViewを位置を調整してみてください – xmhafiz

答えて

0

は、私は、これはあなたがスクリーンショットを共有することができ

関連する問題