UIImageView의 프레임 크기를 UICollectionCell의 하위 클래스 안에 설정하려고하지만 작동하지 않습니다. 나는 스토리 보드를 사용한다.initWithCoder에서 UIImageView 프레임 설정
코드에서 모든 것이 작동하지만 imageView와 관련된 마지막 줄입니다. drawRect에 코드를 넣으면 제대로 작동합니다.
- (id)initWithCoder:(NSCoder *)decoder {
if ((self = [super initWithCoder:decoder]))
{
self.backgroundColor = [UIColor colorWithWhite:0.85f alpha:1.0f];
self.layer.borderColor = [UIColor lightGrayColor].CGColor;
self.layer.borderWidth = 1.0f;
self.layer.cornerRadius = 8.0f;
self.layer.masksToBounds = NO;
self.layer.shadowColor = [UIColor blackColor].CGColor;
self.layer.shadowRadius = 3.0f;
self.layer.shadowOffset = CGSizeMake(0.0f, 2.0f);
self.layer.shadowOpacity = 0.5f;
self.imageView.frame = CGRectMake(10, 10, 50, 50);
}
아니요 layoutSubviews에서 작동하지 않습니다. 뷰가 나중에 이동되지 않습니다 ... drawRect있는 메서드를 호출하여 문제를 해결했습니다 (최적은 아니지만 작동합니다) – Sucrenoir