【原】iOS學習之圖片展開處理(類似qq的氣泡),ios展開

來源:互聯網
上載者:User

【原】iOS學習之圖片展開處理(類似qq的氣泡),ios展開

原理是展開裡面的內容,將邊保護起來

方法1:

①[image resizableImageWithCapInsets:UIEdgeInsetsMake(30, 30, 30, 30)];②[image resizableImageWithCapInsets:UIEdgeInsetsMake(30, 30, 30, 30) resizingMode:UIImageResizingModeStretch]; typedef NS_ENUM(NSInteger, UIImageResizingMode) {    UIImageResizingModeTile,(瓦片)    UIImageResizingModeStretch,(伸展) };

上述的方法是將圖片沒有保護的部分進行展開。

①直接傳入保護的範圍,沒有設定圖展開的模式,預設為UIImageResizingModeTile(瓦片式)就是將圖片以原來的大小就行平鋪顯示

②設定圖片展開的模式

 

方法2:

[image stretchableImageWithLeftCapWidth:image.size.width * 0.5 topCapHeight:image.size.height * 0.5];

蘋果原始就存在的方法,已經被捨棄,這個方法只會展開中間 1*1 的地區

一般傳入的值為圖片大小的一半

計算公式為:

    // left(傳入)

    // top(傳入)

    // width
    // height
    // right = width - left - 1;(計算)
    // 1 = width - left - right;

    // bottom = height - top - 1;(計算)

    // 1 = height - top - bottom;

 

方法3:

不需要寫代碼

將圖片拖拽到images.xcassets,具體設定步驟如:

將圖片按照方法設定後,圖片會一直可以展開

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.