How to stretch the image size in iphone UIImage or UIImageView

后端 未结 3 598
故里飘歌
故里飘歌 2020-12-30 11:15

I\'d like to show an image in an iPhone app, but the image I\'m using is too big. I\'d like to scale it to fit the iPhone screen, I can\'t find any class to handle it.

3条回答
  •  北海茫月
    2020-12-30 12:04

    UIImageView* view = [[UIImageView alloc] initWithImage: [UIImage imageNamed: @"your_image.png"]];
    view.frame = CGRectMake(0, 0, width, height);
    

    To get the frame of the iPhone screen you can use

    CGRect frame = [[UIScreen mainScreen] bounds];
    

提交回复
热议问题