Saturday, 24 August 2013

Custom UIView resizing while rotating

Custom UIView resizing while rotating

I know that there are several similar questions, but I still didn't find a
proper solution. I've just created a test project with a custom view:
@interface CustomView : UIView
//..
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self setBackgroundColor:[UIColor redColor]];
}
return self;
}
and View Controller:
- (void)viewDidLoad
{
[super viewDidLoad];
CustomView *cv = [(CustomView *) [CustomView alloc]
initWithFrame:self.view.frame];
[self.view addSubview: cv];
}
In the Landscape Mode we can see:

How to fix it? I know about layoutSubviews, but 1. it's not called while
rotating; 2. How I can resize a view here?

No comments:

Post a Comment