autoresize只能设置父子控件之间的位置关系!
UIView *redView = [[UIView alloc] init];
redView.frame = CGRectMake(self.view.frame.size.width-250, self.view.frame.size.height-250, 200, 200);
redView.backgroundColor = [UIColor redColor];
[self.view addSubview:redView];
/**
UIViewAutoresizingNone
UIViewAutoresizingFlexibleLeftMargin 距离父控件左边可以拉伸
UIViewAutoresizingFlexibleWidth 宽度会随父控件的宽度进行拉伸
UIViewAutoresizingFlexibleRightMargin 距离父控件右边可以拉伸
UIViewAutoresizingFlexibleTopMargin 距离父控件顶部可以拉伸
UIViewAutoresizingFlexibleHeight 宽度会随父控件的高度进行拉伸
UIViewAutoresizingFlexibleBottomMargin 距离父控件底部可以拉伸
*/
// 在屏幕右下角,保持右边50,底部50,高度和宽度碎屏幕拉伸
redView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin| UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
网友评论