AutoResize代码实现

使用AutoResize布局方式,要去掉AutoLayout布局方式,因为两者相冲突。不建议使用这种布局。

CGFloat X = self.view.frame.size.width - 120;
CGFloat Y = self.view.frame.size.height - 120;

UIView *redView = [[UIView alloc] initWithFrame:CGRectMake(X, Y, 100, 100)];
redView.backgroundColor = [UIColor redColor];
[self.view addSubview:redView];

/**
 autoresizingMask是枚举,其值如下:
 UIViewAutoresizingNone                 = 0,
 UIViewAutoresizingFlexibleLeftMargin   = 1 << 0,
 UIViewAutoresizingFlexibleWidth        = 1 << 1,
 UIViewAutoresizingFlexibleRightMargin  = 1 << 2,
 UIViewAutoresizingFlexibleTopMargin    = 1 << 3,
 UIViewAutoresizingFlexibleHeight       = 1 << 4,
 UIViewAutoresizingFlexibleBottomMargin = 1 << 5
*/
redView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin;

results matching ""

    No results matching ""