嘗試在UIImageView中設置大圖像時,圖像的分辨率會變形。有沒有什麼辦法讓圖像保持相同的分辨率,而將圖像放在較小的視圖中?UIImageView圖像在放置大圖像時發生扭曲
4
A
回答
5
嘗試將imageview內容模式設置爲aspectfit。
imageView.contentMode = UIViewContentModeScaleAspectFit;
3
UIViewContentModeScaleToFill
Scales the content to fit the size of itself by changing the aspect ratio of the content if necessary.
Available in iOS 2.0 and later.
Declared in UIView.h.
UIViewContentModeScaleAspectFit
Scales the content to fit the size of the view by maintaining the aspect ratio. Any remaining area of the view’s bounds is transparent.
Available in iOS 2.0 and later.
Declared in UIView.h.
UIViewContentModeScaleAspectFill
Scales the content to fill the size of the view. Some portion of the content may be clipped to fill the view’s bounds.
Available in iOS 2.0 and later.
Declared in UIView.h.
UIViewContentModeRedraw
Redisplays the view when the bounds change by invoking the setNeedsDisplay method.
Available in iOS 2.0 and later.
Declared in UIView.h.
UIViewContentModeCenter
Centers the content in the view’s bounds, keeping the proportions the same.
Available in iOS 2.0 and later.
Declared in UIView.h.
UIViewContentModeTop
Centers the content aligned at the top in the view’s bounds.
Available in iOS 2.0 and later.
Declared in UIView.h.
UIViewContentModeBottom
Centers the content aligned at the bottom in the view’s bounds.
Available in iOS 2.0 and later.
Declared in UIView.h.
UIViewContentModeLeft
Aligns the content on the left of the view.
Available in iOS 2.0 and later.
Declared in UIView.h.
UIViewContentModeRight
Aligns the content on the right of the view.
Available in iOS 2.0 and later.
Declared in UIView.h.
UIViewContentModeTopLeft
Aligns the content in the top-left corner of the view.
Available in iOS 2.0 and later.
Declared in UIView.h.
UIViewContentModeTopRight
Aligns the content in the top-right corner of the view.
Available in iOS 2.0 and later.
Declared in UIView.h.
UIViewContentModeBottomLeft
Aligns the content in the bottom-left corner of the view.
Available in iOS 2.0 and later.
Declared in UIView.h.
UIViewContentModeBottomRight
Aligns the content in the bottom-right corner of the view.
Available in iOS 2.0 and later.
Declared in UIView.h.
2
設定尺寸後設置contentMode
[imageView setContentMode: UIViewContentModeScaleAspectFit];
imageView.frame = CGRectMake(x, y, width, height);
+0
謝謝,非常有價值的信息。 –
1
我的圖像調整到包含圖像的UIImageView的大小固定的這個問題必須發生。
對我而言,imageView.contentMode = UIViewContentModeScaleAspectFit
也沒有設置imageView的框架工作。
方案:
我使用從XIB一個UITableViewCell,它有一個的UIImageView。我以編程方式設置了UIImageView的圖像。
相關問題
- 1. 縮放位圖輸出扭曲圖像
- 2. VTK圖像扭曲?
- 3. 扭曲的地圖圖像
- 4. 扭曲的位圖圖像
- 5. 作物扭曲/縮放圖像
- 6. Drupal圖像壓縮 - 扭曲圖像
- 7. 圖像在上傳時被扭曲
- 8. WooCommerce中產品圖像扭曲/太大
- 9. OpenCV stereoRectify扭曲圖像
- 10. CGImageRef旋轉扭曲圖像
- 11. Opencv - 圓形圖像扭曲
- 12. Android - 圖像扭曲效果
- 13. Python urllib2圖像扭曲
- 14. Android OpenGL ES扭曲圖像
- 15. 臉部像箱子圖像扭曲
- 16. PHP功能彎曲/扭曲圖像
- 17. 使用高度圖扭曲圖像?
- 18. 縮放時扭曲的內容UIImageView
- 19. UIImageView不讓我放大圖像
- 20. 視角在茱莉亞扭曲圖像
- 21. PNG圖像在IE7中扭曲泥濘
- 22. Opencv攝像機校準生成非常扭曲的圖像
- 23. 爲什麼我的背景圖像在MacBook上查看時發生扭曲?
- 24. UIImageView圖像自動縮放
- 25. monodroid如何在圖像上放置圖像並放置圖像
- 26. UIImageView與大圖像。問題
- 27. 作物圖像php變形,扭曲
- 28. 全角圖像扭曲取向變化
- 29. HTC Desire上的扭曲背景圖像
- 30. iOS - CATiledLayer renderInContext:結果扭曲的圖像
UIViewContentModeScaleAspectFit適合圖像,並剪切其餘部分。有沒有辦法使圖像適合imageview的大小而不失真? –
嘗試使用Aspectfill來經常在圖像視圖中設置圖像而不失真。 – Ronak