0

私はPinterestのことを考えて、製品情報でUICollectionView多くを再利用しているところがあります。UICollectionViewCells

しかし、私が値札を持っていて、すべてのセルに対して価格リボンを約45度回転させたいと思うようになりました。

グリーンプライスリボンにご注意ください

それを達成するための最良のパフォーマンスの賢明な方法は何でしょうか?

私は試しました:

#import <QuartzCore/QuartzCore.h>

@interface ItemCollectionViewCell : UICollectionViewCell

@property (weak, nonatomic) IBOutlet UILabel *price;

@end


@implementation ItemCollectionViewCell

@synthesize price;

- (void)awakeFromNib {
    price.layer.transform = CATransform3DMakeRotation(M_PI_4, 0, 0, 1);
    price.layer.transform = CATransform3DTranslate(price.transform, 25, -15, 0);
    price.layer.shouldRasterize = YES;
}

@end

ただし、新しいビューをスクロールしてナビゲーションコントローラにプッシュすると、全体的な結果は非常に遅くなります。

アップデート

  • iOS6の自動レイアウトがパフォーマンス低下の主な原因のようですが、これを修正する方法や、価格ラベルのみの自動レイアウトを削除する方法がまだわかりません。
4

1 に答える 1

3

私のために働いたのは、ラベルUICollectionViewCellの制約を設定するiOS6autoLayout機能によって定義された属性を削除することでした。price

- (void)awakeFromNib {

    NSMutableArray* cons = [NSMutableArray array];
    //iterating through UICollectionViewCell constraint list
    for (NSLayoutConstraint* con in self.constraints) {
        //if the target constraint is `price` then add that to the array
        if (con.firstItem == price || con.secondItem == price) {
            [cons addObject:con];
        }
    }
    //remove the unwanted constraints array to the UICollectionViewCell
    [self removeConstraints:cons];

    //ready to roll…
    price.layer.transform = CATransform3DMakeRotation(M_PI_4, 0, 0, 1);
    price.layer.transform = CATransform3DTranslate(price.transform, 25, -15, 0);
    price.layer.shouldRasterize = YES;
}
于 2013-01-16T13:03:36.340 に答える