UIImage View的contentMode的屬性理解

UIViewContentModeScaleToFill ?//不是按照比例放大,把整個(gè)view撐滿,失真,扭曲

UIViewContentModeScaleAspectFit //按照比例放大,保持圖片原有的比例,不會(huì)扭曲,導(dǎo)致view會(huì)有些空白

UIViewContentModeScaleAspectFill // 按比例放大,同時(shí)撐滿整個(gè)view,導(dǎo)致有一部分不會(huì)顯示

UIViewContentModeRedraw // 重繪視圖邊界

UIViewContentModeTop, 視圖頂部對(duì)齊

UIViewContentModeLeft, 視圖左側(cè)對(duì)齊

UIViewContentModeCenter,// contents remain same size. positioned adjusted.? 視圖保持等比縮放

參考文章:http://www.dreamingwish.com/article/coreanimation-programming-guide-e-the-content-layer.html

CALayer與 contentMode對(duì)應(yīng)的屬性叫做contentsGravity,但是它是一個(gè)NSString類型,而不是像對(duì)應(yīng)的UIKit部分,那里面的值是枚舉。contentsGravity可選的常量值有以下一些:

Scaling constant

Description

kCAGravityResize

Resize the content image to completely fill the layer bounds, potentially ignoring the natural aspect of the content. This is the default.

kCAGravityResizeAspect

Resize the content image to scale such that it is displayed as large as possible within the layer bounds, yet still retains its natural aspect.

kCAGravityResizeAspectFill

Resize the content image to scale such that it is displayed filling the layer bounds, yet retaining its natural aspect. This may cause the content to extend outside the layer bounds.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 1. SOCIAL MEDIA: INTEREST-BASED OR NETWORK BASED PUBLIC O...
    Novazyyy閱讀 144評(píng)論 0 0
  • 這幾天因?yàn)槭崂硭卣f·慈心齋品牌文化的緣故,不斷在尋問自己“人生命存在的意義”。其實(shí)很多年前,我有過覺得人生很...
    墨竹的菜園閱讀 344評(píng)論 0 1

友情鏈接更多精彩內(nèi)容