如何自动调节的UIView帧到另一帧的UIView
问题描述:
我有UIViewcontroler
其具有两个组件的大小宽度之一UITableView
占用:120和高度:603的UIViewcontroller
和另一个UIView
(的DetailView)相关的屏幕。 (尺寸宽度:255 &身高:603)如何自动调节的UIView帧到另一帧的UIView
现在我定制UIView
创建(customView)现在我想补充它的DetailView,它不适合UIView
的DetailView Frame是UIViewController中的一半查看大小。 定制视图帧正常即宽度375 &高度667
-(void)loadView {
NSArray *nibObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomView" owner:self options:nil];
customView = [nibObjects objectAtIndex:0];
customView.frame = detailView.frame;
customView.layer.shadowColor = [UIColor blackColor].CGColor;
customView.layer.shadowRadius = 1.0f;
customView.layer.shadowOpacity = 1;
customView.layer.shadowOffset = CGSizeZero;
customView.layer.masksToBounds = YES;
[detailView addObject:customView];
}
的CustomView不是自动上的DetailView UIView的屏幕调整。 的理解来解决框架
@Thanks提前
答
的问题是您在的DetailView的框架设置为您customView并添加customView到您的DetailView你的建议将是有益的。
设置自定义视图的框架,请使用以下代码:
customView.frame = (CGRect){
.origin = CGPointZero,
.size = detailView.frame.size
};
希望充分,这将解决您的问题。
答
你的loadView方法是这样写下面
-(void)loadView {
NSArray *nibObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomView" owner:self options:nil];
customView = [nibObjects objectAtIndex:0];
customView.frame = CGRectMake(0, 0, detailView.frame.size.width, detailView.frame.size.height);
customView.layer.shadowColor = [UIColor blackColor].CGColor;
customView.layer.shadowRadius = 1.0f;
customView.layer.shadowOpacity = 1;
customView.layer.shadowOffset = CGSizeZero;
customView.layer.masksToBounds = YES;
[detailView addSubview:customView];
}
什么是detailView.frame中的loadView方法?你在哪里调用这个方法? –
@TejaNandamuri CustomView.frame = detailView.bounds;它有助于解决这个问题。我一会儿就哑了。 :d – kiran