我在 Core Data 中保存了几个视图参数,这些参数缩放以适应self.view
. 当我获取视图参数时,我想重新缩放视图以适应较小的父视图 ( newView
)。如何让viewSelected
子视图在newView
父视图中调整大小?
newView = [[UIView alloc]initWithFrame:CGRectMake(100, 100, 200, 200)];
newView.autoresizesSubviews = YES;
for (Shape *shape in shapes) {
ShapeView *viewSelected = [[SquareView alloc]init];
[viewSelected setAutoresizingMask:UIViewAutoresizingFlexibleHeight |
UIViewAutoresizingFlexibleWidth];
viewSelected.frame = CGRectMake(shape.x,shape.y,shape.shapeSize,shape.shapeSize);
[newView addSubview:viewSelected];
}
[self.view addSubview:newView];