简体   繁体   中英

xCode CGRectMake will only draw a square?

I am trying to draw a simple rectangle shaped label but when I run my code, the app always draws a square? Here is my code.

UILabel *box =[[UILabel alloc] initWithFrame:CGRectMake(0,100,100,20)];
box.backgroundColor = [UIColor redColor];
[self.view addSubview:box];

Can anyone help me?

Check your superview autoresize mask. It happens when superview autoresize mask is flexible for width for itself and its subviews.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM