在 UITableViewCell 子类中旋转 UIImageView



所以我有以下代码:

#define degreesToRadians(x) (M_PI * x / 180.0)
@implementation NewsFeedSubCell
@synthesize imageView_;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {

        CGRect frame = self.frame;
        frame.size.width = 20;
        frame.size.height = 20;
        self.frame = frame;
        self.contentView.frame = frame;
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.frame];
        imageView.transform = CGAffineTransformRotate(self.contentView.transform, degreesToRadians(90));
        [imageView setAutoresizingMask:UIViewAutoresizingNone];
        [self.contentView addSubview:imageView];
        self.imageView_ = imageView;
        [imageView release];

    }
    return self;
}

知道为什么这不旋转吗?

为什么要转换内容视图?尝试使用CGAffineTransformMakeRotation而不是CGAffineTransformRotate

最新更新