In my UIView
subclass' .h:
@interface MyView : UIView
@property (nonatomic, strong) UIImageView *imageView;
@end
I'm setting up the UIImageView
on my UIView
subclass like this (init
method):
self.imageView = [[UIImageView alloc]initWithFrame:CGRectMake(5, 0, 34, 34)];
self.imageView.layer.cornerRadius = CGRectGetWidth(imageView.frame) / 2.0f;
self.imageView.layer.masksToBounds = YES;
self.imageView.backgroundColor = [UIColor someColor];
[self addSubview: self.imageView];
So, I can do myView.imageView.image = [UIImage someImage]
and it sets the image on the UIImageView
correctly. My problem comes when trying to clean up the code on my UIView
subclass.
I'm trying to do this:
- (UIImageView *)imageView {
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(5, 0, 34, 34)];
imageView.layer.cornerRadius = CGRectGetWidth(profilePhotoImageView.frame) / 2.0f;
imageView.layer.masksToBounds = YES;
imageView.backgroundColor = [UIColor redColor];
return imageView;
}
and then from the init
method do
[self addSubView: [self imageView]];
But when I do myView.imageView.image = [UIImage someImage]
the image doesn't show on the UIImageView.
What am I forgetting?