syn*_*gma 8 objective-c uiimageview
我UIImageView在里面创建了一个使用的Storyboard UIViewController.
我正在尝试重新缩放图像的宽度以适合屏幕宽度并按比例重新缩放高度:
[fImage setImage:[UIImage imageNamed: @"f2345.jpeg"]];
[fImage sizeToFit];
fImage.contentMode = UIViewContentModeScaleAspectFit;
CGRect frame = filmImage.frame;
frame.size.width = [[UIScreen mainScreen] bounds].size.width;
// Alternative way to do the similar thing - gives the same result in my case
// frame.size.width = [[UIScreen mainScreen] applicationFrame].size.width;
fImage.frame = frame;
Run Code Online (Sandbox Code Playgroud)
然后它显示一个缩放的图像,但它适合其他区域,并且我的图像中有一个空白区域.
ser*_*gio 13
尝试使用此代码:
float imgFactor = frame.size.height / frame.size.width;
frame.size.width = [[UIScreen mainScreen] bounds].size.width;
frame.size.height = frame.size.width * imgFactor;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9343 次 |
| 最近记录: |