2016-03-28 12 views
1

カスタムラベルを持つカスタムUICollectionViewCellがあります。ユーザーがセルをタップすると、アニメーションにカスタムラベルの外観が表示されます。私は参照変数を保持し、collectionView.reloadData()を呼び出すことを試みましたが、私のcellForItemAtIndexPathでは更新がアニメーション化されません。むしろ、それは即座に起こります。ラベルのフォントとサイズの変更をどのようにアニメーション化できますか?選択時にUICollectionViewCellラベルをアニメーション化する

func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) { 

     self.flatPicker.reloadData() 
     self.variable = indexPath.row 

} 

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { 

     let cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as! UICollectionViewCell 

     cell.label.text = self.array[indexPath.row] 

     if indexPath.row == variable { 

      UIView.animateWithDuration(2, animations: { 

       cell.label.font = UIFont.boldSystemFontOfSize(12) 
       cell.label.textColor = UIColor.darkGrayColor() 

      }) 


     } else { 

      UIView.animateWithDuration(2, animations: { 

       cell.label.font = UIFont.systemFontOfSize(11) 
       cell.label.textColor = UIColor.lightGrayColor() 

      }) 

     } 

     return cell 
    } 
+0

リロードしない... didSelectItemAtIndexPathで参照を取得し、そのセルだけをアニメーション化します。 私はよく分かりませんが、メソッドcellForRowAtIndexPathがあると思います。その後、didSelectItemAtIndexPathの参照を取得してアニメーション化することができます。 – UlyssesR

答えて

0

フォントとテキストの色はアニメーション化できません。あなたは何ができるか

はあなたがcellForItemAtIndexPathではなくdidSelectItemAtIndexPathで選択したセルをacccessべきではない.alpha

0

を使用して、2つの間の太字/通常の属性とのクロスフェードのいずれかで互いの上に2つのラベルを層であります。

は、現在選択されたセルを盗んとDavidフォントと色がアニメーション特性ではないと述べたように

func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) { 
    let cell = collectionView.cellForItemAtIndexPath(indexPath) 
    cell.label.font = UIFont.boldSystemFontOfSize(12) 
    cell.label.textColor = UIColor.darkGrayColor() 

}

ようにそれをアニメート。

関連する問題