你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> 一個從UIImageView中獲得Image位置的函數

一個從UIImageView中獲得Image位置的函數

編輯:IOS開發綜合
[cpp]      [cpp]   (CGRect)getFrameSizeForImage:(UIImage *)image inImageView:(UIImageView *)imageView {            float hfactor = image.size.width / imageView.frame.size.width;      float vfactor = image.size.height / imageView.frame.size.height;            float factor = fmax(hfactor, vfactor);            // Divide the size by the greater of the vertical or horizontal shrinkage factor      float newWidth = image.size.width / factor;      float newHeight = image.size.height / factor;            // Then figure out if you need to offset it to center vertically or horizontally      float leftOffset = (imageView.frame.size.width - newWidth) / 2;      float topOffset = (imageView.frame.size.height - newHeight) / 2;            return CGRectMake(leftOffset, topOffset, newWidth, newHeight);     廢話不多說貼代碼。再stackOverflow中找到的馬克下!
  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved