I have a custom UIView. in initWithFrame I add image
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.bgImage = [[[UIImageView alloc] initWithFrame:
CGRectMake(frame.size.width - 10, 20, 50 , 50)] autorelease];
[self.bgImage setImage:[UIImage imageNamed:@"myImage.png"];];
}
return self;
}
Everything is fine when I create my custom UIView. But when I change it’s frame, my image position didn’t changed. How to fix that ? Tried with autoresize mask, but it didn’t help.
Override
layoutSubviewslike so:Basically, this gets called whenever a re-layout is needed. So you should set the frame of any subviews as you need to.