簡體   English   中英

如何使用UIImageView和UIImage配置適當的視圖大小?

[英]How to config proper view size with UIImageView and UIImage?

我是iOS編程的新手,現在我正在使用AVFoundation編寫相機應用程序。 我的問題是我必須預覽僅以全屏尺寸拍攝的圖像,但是無論如何嘗試,我都只是在手機上以全屏尺寸顯示了裁剪后的圖像(原始圖像的左上比例)。 我剛拍攝的圖像分辨率為1920 * 1080分辨率,我的UIImageView設置為AspectFit,並且在情節提要中,它以全屏尺寸顯示。

顯示圖像的代碼就像

   [self.imageView setFrame:self.view.bounds];
   [self.imageView setContentMode:UIViewContentModeScaleAspectFit] ;
   [self.imageView setImage:image] ;
   [self.view insertSubview:_imageView aboveSubview:_previewView] ;
   [self.view bringSubviewToFront:_stillButton] ;
   [self.view bringSubviewToFront:_maskButton] ;
   [self.view bringSubviewToFront:_confirmButton] ;

當我觀察UIImageView對象self.imageView的大小時,該大小不是屏幕大小,而是320 * 568。 但是,previewView是AVFoundation相機拍攝的預覽對象,也是320 * 568,但是從正在運行的應用程序的外觀來看,previewView的大小是正確的。 最后,self.view.frame.size也是320 * 568。

所以我的問題是如何以全屏尺寸查看1920 * 1080拍攝的圖像?

試試這個: imageView.contentMode = UIViewContentModeCenter

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM