简体   繁体   中英

how to make UIView subview a fixed size programmatically

I have a UIView subclass that I want to be 50x50; When I load it it always takes up the entire screen How can I solve this?

Posting some code would help us help you, but here's how you set the frame of any UIView subclass:

// When creating the view...
UIView *yourView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];

// or after having created the view...
yourView.frame = CGRectMake(0, 0, 50, 50);
// ... or
[yourView setFrame:CGRectMake(0, 0, 50, 50)];

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