简体   繁体   中英

How to set UIImage frame

我如何设置UIImage的帧大小。

You can set the frame of the UIImageView :

UIImageView* imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
imgView.image = [UIImage imageNamed:@"image.png"];

(and don't forget to [imgView release]; somewhere)

UIImage has no frame. It has only width and height. If you want to put it on your view you should create UIImageView

UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(12,12,123,123)];
imageView.image = image; // image - your UIImage

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