2012-10-04 52 views
0

我使用UIImageView控件從字節數組創建圖像。我需要確保圖像的最大尺寸是600 x 600.我該怎麼做?我試過SizeThatFits()和SizeToFit(),但是,它只是在屏幕上移動圖像。我已經嘗試將Bound屬性設置爲新的RectangleF(0,0,600,600),但是,這也沒有好處。ImageView Max Size iOS MonoTouch

回答

1

您可以檢查UIImage Size屬性是否超出限制。如果是這樣,它scale

const int limit = 600; 
if ((View.Frame.Size.Width > limit) || (View.Frame.Size.Height > limit)) 
{ 
    // Scale as on link above. 
} 

或者,你可以設置你的UIImageView的框架和ContentMode到理想值。