0

先生、私は初心者です。私はこれを理解することができません。 collectionViewをスクロールしている間、私は遅れに直面しています。私は細胞影を取り除き、遅れがなくなった。しかし、私は影を追加したい。私の携帯電話の商品コードは:スクロール中のCollectionViewの遅れ

- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath 
    { 
     NSString *cellIdentifier = @"cellCollection"; 
     [self.MainCollectionView registerClass:[CVC_ImageWithLabel class] forCellWithReuseIdentifier:cellIdentifier]; 
     CVC_ImageWithLabel *customCell = (CVC_ImageWithLabel *)[self.MainCollectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath]; 

     //cell text 
     customCell.NameLabel.text = [data_Array objectAtIndex:indexPath.row]; 
     //cell image 
     customCell.CellImage.image=[UIImage imageNamed:[image_Array objectAtIndex:indexPath.row]]; 
     customCell.CellImage.contentMode = UIViewContentModeScaleAspectFit; 

     return customCell; 
    } 

私を助けてくれますか? 以下のコードを追加しようとしましたが、失敗しました。

customCell.layer.shouldRasterize = YES; 
customCell.layer.rasterizationScale = [UIScreen mainScreen].scale; 
+0

cellForItemにコードを追加 – karthikeyan

+0

フルコードが追加されました。 –

+0

このビューを追加します。[セル。 – karthikeyan

答えて

1

- shadowPath:

self.layer.shadowRadius = 5; 
self.layer.shadowOpacity = 0.5; 
self.layer.shadowOffset = CGSizeMake(0, 1); 
self.layer.shadowColor = [UIColor blackColor].CGColor; 
self.layer.shadowPath = [UIBezierPath bezierPathWithRoundedRect: self.bounds cornerRadius: self.layer.shadowRadius].CGPath; 

このパスではなく、層の合成さアルファチャンネルを使用しての層の影を構築するために使用されるアウトラインを定義します。このプロパティを使用して明示的にパスを指定すると、通常はレンダリングのパフォーマンスが向上します

+0

はい、少し改善します。ありがとうございました。 –

0

シャドウを画像として追加すると、パフォーマンスが向上します。イメージのスライスを使用すると、イメージのスケーリングに役立ちます。

セットアップ層の1つの以上の特性をすべき
+0

いくつかのコードを共有できますか? –

関連する問題